October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
automated testing

How to Fix Blank Protractor Screenshots When `restartBrowserBetweenTests` Is Enabled

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A blank Protractor failure screenshot usually means the browser was restarted before the failure hook captured the page. Capture and attach the screenshot first, then restart the browser. In Protractor’s configuration, restartBrowserBetweenTests defaults to false; enabling it restarts the browser between tests and can slow the suite significantly.

Why the screenshot is blank

Protractor drives a real browser through WebDriverJS. A WebDriver screenshot command captures the viewport of the top-level browsing context and returns PNG data encoded as base64. It records whatever state exists when the command runs.

With a Cucumber or similar After hook, the sequence can accidentally become:

  1. The scenario fails.
  2. The browser is restarted because restartBrowserBetweenTests is enabled, or because the hook calls browser.restart().
  3. The failure hook asks WebDriver for a screenshot.
  4. The screenshot contains a blank, newly opened page rather than the failed scenario.

This is a lifecycle-ordering problem reported for a Protractor/Cucumber setup, not proof that every Protractor version or runner orders hooks identically. Verify the order in your own framework, runner and installed versions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Logitech Brio 101 Full HD 1080p Webcam for Streaming and Meetings - Black
  • Compatible with Nintendo Switch 2’s new GameChat mode
  • Auto-Light Balance: RightLight boosts brightness by up to 50%, reducing shadows so you look your best—compared to previous-generation Logitech webcams (1)
  • Privacy with a Slide: The integrated webcam cover makes it easy to get total, reliable privacy when you're not on a video call
  • Built-In Mic: The built-in microphone lets others hear you clearly during video calls
  • Easy Plug-And-Play: The Brio 101 works with most video calling platforms, including Microsoft Teams, Zoom and Google Meet—no hassle; it just works

Check the configuration first

Find the setting

Open the Protractor configuration file used by the failing job, commonly a file such as protractor.conf.js, and search for:

restartBrowserBetweenTests: true

The documented default is false. If the property is absent, Protractor normally does not restart between tests. Also check whether a helper, custom framework adapter or hook calls browser.restart() directly.

Decide whether a restart is required

Restarting can provide stronger isolation when tests leave behind cookies, local storage, windows or other browser state. The Protractor configuration warning says that enabling the option can slow tests drastically; it is a warning about configuration cost, not a published timing benchmark. If your tests do not require a fresh browser process for every test, compare the default setting with the isolation benefit before accepting that cost.

Capture before restarting

The essential fix is to make the screenshot operation finish before any restart begins. Return or await the screenshot promise so the hook cannot proceed early.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Promise-based Cucumber-style hook

This pattern captures the viewport, attaches the PNG to the scenario, and only then restarts the browser:

After(async function (scenario) {
  if (!scenario.result || scenario.result.status !== 'failed') {
    return;
  }

  const pngBase64 = await browser.takeScreenshot();
  this.attach(Buffer.from(pngBase64, 'base64'), 'image/png');

  // Restart only after capture and attachment have completed.
  await browser.restart();
});

The exact attachment API differs between Cucumber versions. If this.attach is callback-based in your version, wrap it in a promise and await that promise as well. The important ordering is screenshot command, attachment completion, then restart.

Rank #2
Sale
EMEET C960 1080P Webcam with Microphone, 2 Mics, 90° FOV, Computer Camera
  • 1080P Webcam with Cover for Video Calls - EMEET computer webcam provides design and Optimization for professional video streaming. Realistic 1920 x 1080p video, 5-layer anti-glare lens, providing smooth video. C960 computer camera delivers 1920x1080 video with fixed focus (11.8–118.1 inches), so as to provide a clearer image. C960 USB webcam has a cover and can be removed automatically to meet your needs for privacy. For optimal image performance, use the webcam in a well-lit environment.
  • Built-in 2 Omnidirectional Mics - EMEET webcam with microphone for desktop features 2 built-in omnidirectional microphones, picking up your voice to create clear audio for communication. When installing the webcam, select EMEET C960 as the default microphone input device in your computer and video applications and select C960 as the default device in Zoom/Teams and ensure microphone permissions are enabled for proper use. Please note that C960 does not include built-in speakers.
  • Automatic Light Adjustment - Automatic exposure adjustment is applied in EMEET HD webcam 1080p so that the streaming webcam can deliver stable image performance. EMEET C960 camera for computer also features color adjustment and exposure optimization to help you look your best. For optimal video quality, it is recommended to use the webcam in normal or well-lit environments and select suitable video settings in your application. Proper lighting helps achieve a clearer and more balanced image.
  • Plug-and-Play & Upgraded USB Connectivity - New C960 webcam features both USB Type-A & A-to-C adapter connections for wider compatibility. For stable performance, connect the webcam directly to the computer's main USB port and ensure the device is recognized correctly. If a hub or docking station is used, please ensure it provides sufficient power and stable data transmission, as limited ports may affect performance. 90° wide-angle lens captures more participants without frequent adjustments.
  • High Compatibility & Multi Application - C960 webcam for laptop is compatible with Windows 10/11, macOS 10.14+, and Android TV 7.0+. Not supported: Windows Hello, TVs, tablets, or game consoles. It works with Zoom, Teams, Facetime, Google Meet, YouTube and more. Please select C960 webcam as the default camera and microphone device in your application and ensure camera/microphone permissions are enabled, especially on macOS. (Tips: Incompatible with Windows Hello)

Explicit promise chain

For runners that do not support async/await, return the complete chain:

After(function (scenario) {
  if (!scenario.result || scenario.result.status !== 'failed') {
    return Promise.resolve();
  }

  return browser.takeScreenshot()
    .then(function (pngBase64) {
      return new Promise(function (resolve, reject) {
        try {
          this.attach(Buffer.from(pngBase64, 'base64'), 'image/png');
          resolve();
        } catch (error) {
          reject(error);
        }
      }.bind(this));
    }.bind(this))
    .then(function () {
      return browser.restart();
    });
});

Adapt the attachment call to your reporter. Do not start the restart in a separate, unreturned promise: the runner may finish the hook while capture is still pending.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Two reliable configuration patterns

Pattern A: leave automatic restarts disabled

Set the option to its documented default and perform an explicit restart after the failure artifact has been captured:

exports.config = {
  restartBrowserBetweenTests: false
};

Then place await browser.restart() after screenshot attachment in the hook. This makes the order visible in one place and lets you restart only where isolation is needed.

Pattern B: keep automatic restarts, move the capture earlier

If every test must use a fresh browser, retain:

exports.config = {
  restartBrowserBetweenTests: true
};

Move failure capture to a hook that is guaranteed to run before Protractor performs its between-test restart. The community report that motivated this fix used an After hook and solved the blank image by capturing and attaching first, then calling browser.restart(). Do not assume that another framework schedules hooks the same way; inspect its lifecycle documentation and log the actual order.

A step-by-step diagnostic sequence

  1. Confirm the symptom. Open the attachment and determine whether it is a blank page, a browser start page or an image with no application content.
  2. Record versions and runner. Note Protractor, WebDriver, browser, driver and test-framework versions. The reported failure does not establish a universal affected-version range.
  3. Search all restart paths. Check restartBrowserBetweenTests, calls to browser.restart(), and shared hooks or wrappers that may restart indirectly.
  4. Log lifecycle boundaries. Log immediately before screenshot, immediately after screenshot data is returned, immediately after attachment, and immediately before and after restart.
  5. Temporarily disable automatic restart. Set the option to false and run one failing scenario. If the image is now correct, ordering is the leading explanation.
  6. Restore isolation deliberately. Either keep automatic restart off and restart after capture, or move capture to a pre-restart hook while retaining the setting.
  7. Validate the attachment bytes. Decode the base64 value and confirm the reporter receives PNG data, not an empty string or a promise object.

When ordering is not the cause

A blank capture alone cannot identify the lifecycle event that produced it. If the browser was still alive when the command ran, inspect the state at that instant:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
NexiGo N60 1080P Webcam with Microphone, Software Control & Privacy Cover, USB HD Computer Web Camera, Plug and Play, for Zoom/Skype/Teams, Conferencing and Video Calling
  • 【Full HD 1080P Webcam】Powered by a 1080p FHD two-MP CMOS, the NexiGo N60 Webcam produces exceptionally sharp and clear videos at resolutions up to 1920 x 1080 with 30fps. The 3.6mm glass lens provides a crisp image at fixed distances and is optimized between 19.6 inches to 13 feet, making it ideal for almost any indoor use.
  • 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 8, 10 & 11 / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.
  • 【Built-in Noise-Cancelling Microphone】The built-in noise-canceling microphone reduces ambient noise to enhance the sound quality of your video. Great for Zoom / Facetime / Video Calling / OBS / Twitch / Facebook / YouTube / Conferencing / Gaming / Streaming / Recording / Online School.
  • 【USB Webcam with Privacy Protection Cover】The privacy cover blocks the lens when the webcam is not in use. It's perfect to help provide security and peace of mind to anyone, from individuals to large companies. 【Note:】Please contact our support for firmware update if you have noticed any audio delays.
  • 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 10 & 11, Pro / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.
  • URL and navigation: log await browser.getCurrentUrl() immediately before capture and verify navigation has completed.
  • Window context: check that the test has not switched to a closed or unintended window.
  • Frame context: switch back to the expected top-level browsing context before taking the screenshot.
  • Rendering timing: wait for the application’s readiness condition rather than relying only on a fixed delay.
  • Browser process health: look for driver disconnects, crashes or a session that has already been invalidated.
  • Reporter handling: verify that the report stores binary PNG data correctly and that the MIME type is image/png.

WebDriver captures the top-level viewport, not every possible browser surface. A page rendered inside an unexpected frame or window may therefore look empty even though another context contains the application.

Common errors and fixes

The screenshot promise is not returned

Symptom: the hook ends, the browser restarts, and the attachment is empty or shows a new page.

Fix: return the promise chain or use await for screenshot, attachment and restart in that order.

The restart happens in another hook

Symptom: moving code inside the visible After hook changes nothing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix: search shared support files and framework adapters for browser.restart() and log every hook. A restart in an earlier hook still invalidates the page before capture.

Automatic and explicit restarts are both enabled

Symptom: the browser is restarted twice, or the next scenario starts with an unexpected session.

Rank #4
Sale
Logitech C270 720p Webcam Plug-and-Play Wide Screen Video Calling - Black
  • Compatible with Nintendo Switch 2’s new GameChat mode
  • Crisp HD 720p/30 fps video calls with diagonal 55° field of view and auto light correction. Compatible with popular platforms including Skype and Zoom.
  • The built-in noise-reducing mic makes sure your voice comes across clearly up to 1.5 meters away, even if you’re in busy surroundings.
  • C270’s RightLight 2 feature adjusts to lighting conditions, producing brighter, contrasted images to help you look good in all your conference calls.
  • The adjustable universal clip lets you attach the camera securely to your screen or laptop, or fold the clip and set the webcam on a shelf. You’re always ready for your next video call.

Fix: choose one owner for the restart. Disable the configuration option if your hook performs the restart, or remove the explicit call and place capture before the framework-managed restart.

Attachment API is callback-based

Symptom: the screenshot command completes, but the report has no image.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix: wrap the callback in a promise and await it. A synchronous-looking attachment call may still enqueue asynchronous work.

The page is blank even with restarts disabled

Symptom: the same blank image appears when no restart occurs.

Fix: investigate URL, window, frame, navigation, rendering and driver health. The restart setting is then not established as the cause.

The suite became much slower

Symptom: enabling the option increases runtime substantially.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix: measure your own suite, identify tests that genuinely require process-level isolation, and consider explicit cleanup or targeted restarts. Protractor documents a significant slowdown warning but does not provide a universal time figure.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Making the fix dependable in CI

  • Capture only on failure unless you need diagnostic images for every scenario.
  • Use one hook that owns artifact capture and one clearly defined place that owns restarting.
  • Keep the screenshot operation and attachment in the same awaited control flow.
  • Include the scenario name, current URL and timestamp in logs, but avoid logging credentials or page secrets.
  • Preserve the original failure if screenshot capture fails; diagnostic code should not hide the test assertion.
  • Run a small matrix with automatic restart disabled, explicit restart after capture, and automatic restart enabled with a pre-restart capture hook.
  • Review parallel execution separately. A shared global browser reference can make one scenario capture another scenario’s state if sessions are not isolated.

Or skip the browser setup

For screenshots that are not tied to a live Protractor failure hook, ScreenshotNeo provides a single HTTP request. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server lets Claude, Cursor and other MCP clients call take_screenshot, get_page_info and capture_pdf.

See the parameter reference and complete options in the ScreenshotNeo documentation. A basic cURL request is:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The equivalent Python request is:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

You can still control full-page capture, lazy-image loading, CSS-selector element capture, dark mode, device and viewport, retina scale, PDF paper and page ranges, custom CSS or JavaScript, clicks, hidden selectors, waits, blocked resources, headers, cookies, user agent, authorization, timezone, geolocation, transparency, resizing, cache TTL, signed image links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage reporting and OpenAPI-compatible parameters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Every plan includes every feature. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to try it without a card.

FAQ

What does restartBrowserBetweenTests do?

It tells Protractor to restart the browser between each test. Its documented default is false.

Does a blank screenshot prove that Protractor restarted too early?

No. It is a strong hypothesis when the restart precedes the capture, but the image could also reflect the wrong window or frame, incomplete navigation, rendering timing, driver failure or reporter handling.

Should I always disable browser restarts?

No. Keep the isolation that your tests require. Disable automatic restarts only when a fresh process is unnecessary or when you replace it with an explicit, correctly ordered restart.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Can I capture a screenshot after calling `browser.restart()`?

Only if you first navigate and wait for the new session to render the intended page. It will not be a screenshot of the failed pre-restart state.

Will ScreenshotNeo replace Protractor failure screenshots?

No. It is useful for independent URL captures and automation; a Protractor failure artifact still needs to be captured from the test browser before that browser is restarted.

Quick Recap

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.