Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Inconsistent webdriver errors when using setSize method

error
synthetics
webdriver

#1

We are experiencing quite rare and inconsistent errors like this:

Script execution failed: WebDriverError: unknown error: failed to change window state to normal, current state is maximized
  (Session info: chrome=72.0.3626.121)
  (Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 4.15.0-1054-aws x86_64)
WebDriverError: unknown error: failed to change window state to normal, current state is maximized
  (Session info: chrome=72.0.3626.121)
  (Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 4.15.0-1054-aws x86_64)
    at Object.checkLegacyResponse (/opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/error.js:546:15)
    at parseHttpResponse (/opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/http.js:509:13)
    at doSend.then.response (/opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/http.js:441:30)
    at process._tickCallback (internal/process/next_tick.js:68:7)
From: Task: WebDriver.manage().window().setSize(2560, 2000)
    at Driver.schedule (/opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
    at Window.setSize (/opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/webdriver.js:1672:25)
    at eval (eval at JobResource.getScriptFn (/opt/runtimes/4.0.0/modules/synthetics-runner/lib/job-resource/index.js:78:19), <anonymous>:42:32)
    at ManagedPromise.invokeCallback_ (/opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/promise.js:1376:14)
    at TaskQueue.execute_ (/opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/promise.js:3084:14)
    at TaskQueue.executeNext_ (/opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/promise.js:3067:27)
    at asyncRun (/opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/promise.js:2927:27)
    at /opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/promise.js:668:7
    at process._tickCallback (internal/process/next_tick.js:68:7)

Our monitor version is LATEST .

This is the relevant part of the script for the setSize method:

.then(function () {
    // Set monitor size and request PDP
    $browser.manage().window().setSize(2560, 2000).then(function() {
        $browser.get('https://google.com/');
        console.log("PDP loaded");
    });

So far we have tried using different methods but with no success. It could be that methods setSize and maximize are no longer working in the newer chrome versions (likely some other preconditions must be met as well). Any way you can confirm if this is the case?

This thread seems to be discussing a similar problem - Inconsistent error when validating my script. The workaround mentioned is not a pretty one and something we would like to avoid (although it may work).

The monitor success rate is ~97.9%. The ~2% of failures are all coming from this error.

We would like to understand the following things:

  1. What is causing the setSize() method to fail. Can we still use it? Is there a workaround?
  2. Why is it failing only ~2% of the time? Since this is a webdriver error this is likely something to do with Selenium webdriver. Is there a way we can adjust the webdriver to not use the preconditions that lead to this failure.

Let us know if any further information is necessary.


#2

This is a big clue. It appears that when the setSize fails, the browser window is already maximized. Is there any other steps in your script, or even the page itself, which sets the window size?


#3

Thank you for your answer.

This is a big clue. It appears that when the setSize fails, the browser window is already maximized.

You would think so. But actually no. This is the first call we are making in the script besides adding a cookie to the page. As far as I know there is nothing modifying the window size on the page (but I’ll double check).

Also how does this explain the script failing only 2% of the time? If there was something modifying the window state it should fail every time. Or am I missing something?


#4

Have you tried setting the window size to maximized and observed any failures? If there is a reason you need the window set to the specific size then you will need someone from support to assist with a deeper investigation.


#5

yea, facing the same issue. Actually some web pages need to have a particular screen size to see all the content and avoid overlays or missing content on the screen. I am trying to find the monitor version when this chrome driver was introduced, so can revert back to the previous version to keep the scripts running.


#6

Was not able to find a solution for the setSize webdriver error. So I reworked the script to use maximize and close, remove overlays manually. 100% up time so far. Still would be nice to know what is causing this issue.


#7

I haven’t been able to find a specific version of Chrome that introduced changes here. But Runtime versions in Synthetics match up to different Chrome versions.

Runtime Chrome
0.4.x Chrome 44
0.5.x Chrome 60
0.6.x / LATEST Chrome 72

These runtimes and their Chrome / Selenium version details can be found here: https://docs.newrelic.com/docs/synthetics/new-relic-synthetics/using-monitors/manage-monitor-runtimes