Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebDriverException: unknown error: failed to change window state to maximized, current state is normal with Chrome 70 & Chromedriver 2.43 on MAC OS X

We are on Macs, using Chrome Version 70.0.3538.67 (Official Build) (64-bit), ChromeDriver 2.43.600229. Chrome windows appear, but URL is stuck at "data:,". (stack trace below)

We found a work-around using Chrome version 69 w/ chromedriver 2.43, however, Chrome continues to insist on updating itself.

We are running Selenium-java 3.4, htmlunit-driver 2.27, testng 6.9.4, junit 4.7 with maven-compiler-plugin 3.6.1, maven-surefire-plugin 2.22.0.

org.openqa.selenium.WebDriverException: unknown error: failed to change window state to maximized, current state is normal
  (Session info: chrome=70.0.3538.67)
  (Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 107 milliseconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'edited', ip: 'edited', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '1.8.0_131'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{mobileEmulationEnabled=false, hasTouchScreen=false, platform=MAC, acceptSslCerts=false, goog:chromeOptions={debuggerAddress=localhost:52400}, acceptInsecureCerts=false, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=, applicationCacheEnabled=false, rotatable=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052), userDataDir=/var/folders/cd/rrq4w8sd3gz92ygpfx5_kwtw0000gp/T/.org.chromium.Chromium.DCVcH3}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, version=70.0.3538.67, browserConnectionEnabled=false, nativeEvents=true, locationContextEnabled=true, cssSelectorsEnabled=true}]
Session ID: adb51408a3b04f990288d09604daa3a9
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:671)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:694)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteWindow.maximize(RemoteWebDriver.java:925)
    at ufis.common.TestSuiteUtils.getDriver(TestSuiteUtils.java:59)
    at ufis.test.cv.categories.research.independentresearch.IndependentResearchValidationTests.setUpClass(IndependentResearchValidationTests.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:517)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:140)
    at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:170)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:104)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
like image 998
user2093025 Avatar asked Oct 18 '18 21:10

user2093025


2 Answers

This error message...

org.openqa.selenium.WebDriverException: unknown error: failed to change window state to maximized, current state is normal

...implies that the ChromeDriver was unable to maximize the window state of Chrome Browser client.


Buggy Mac OSX ChromeDriver Replaced

After Chrome version 70 was released, some of you have reported that using ChromeDriver to maximize browser window on Mac no longer works. ChromeDriver Team have investigated this issue, and created a fix for it. ChromeDriver builds with the fix are now available at the following locations:

  • If you are using Chrome version 70 (the current stable release), please download ChromeDriver version 70.0.3538.97 from https://chromedriver.storage.googleapis.com/index.html?path=70.0.3538.97/
  • If you are using Chrome version 71 (the current beta release), please download ChromeDriver version 71.0.3578.33 from https://chromedriver.storage.googleapis.com/index.html?path=71.0.3578.33/

Snapshot of ChromeDriver Release Email

ChromeDriver_new


However, your main issue is the incompatibility between the version of the binaries you are using as follows:

  • Your JDK version is 1.8.0_131 which is pretty ancient.
    • Upgrade JDK to recent levels JDK 8u181.
  • Your Selenium Client version is 3.4.0 which is almost a year older.
    • Upgrade Selenium to current levels Version 3.14.0.

From another perspective, this issue looks like a regression issue from Feature request : ChromeDriver to support window resizing over a remote connection.

ChromeDriver v2.43 in the Release Notes have explicitly mentioned:

ChromeDriver to support window resizing over a remote connection

However, as per best practices to maximize the Chrome Browser client it is suggested to use ChromeOptions class as follows:

System.setProperty("webdriver.chrome.driver", "C:\\your_directory\\chromedriver.exe");
ChromeOptions opt = new ChromeOptions();
opt.addArguments("disable-infobars");
opt.addArguments("--start-maximized");
opt.addArguments("--disable-extensions");
WebDriver driver = new ChromeDriver(opt);
driver.get("https://google.com");

Reference

You can find a detailed discussion in driver.manage().window().maximize() issue with ChromeDriver 2.33


Update(Nov 20, 2018)

  • ChromeDriver 2.44 has been released.
  • ChromeDriver 2.44 supports Chrome versions 69 to 71
  • This release is similar to ChromeDriver 2.43, but with additional bug fixes.
  • A ChromeDriver that supports chrome 72.x is expected to be released in the early December.
like image 181
undetected Selenium Avatar answered Nov 04 '22 09:11

undetected Selenium


Updating chromedriver to version 2.44 solved the problem for me (sort of). Don't get the error anymore, but window is maximized horizontally beyond the screen. However, the tests work.

Option 1. Install via homebrew

If you have previously installed it via homebrew, it has been moved to cask. So uninstall the old version:

brew uninstall chromedriver

Then install the new version from cask:

brew tap homebrew/cask
brew cask install chromedriver

Now you should have the new version in your path and the error is gone.

Option 2. Download the driver

Download the driver from

https://chromedriver.storage.googleapis.com/index.html?path=2.44/

And place it to your path.

like image 26
Mikko Avatar answered Nov 04 '22 10:11

Mikko