11

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)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
user2093025
  • 113
  • 1
  • 1
  • 7

6 Answers6

9

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:


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.
  • Your Selenium Client version is 3.4.0 which is almost a year older.

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.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
3

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.

Mikko
  • 1,877
  • 1
  • 25
  • 37
1

I observed this issue when running package suite and tried ChromeOptions but didnt work.So have tried this way and worked for me:

   Dimension ExpectedDimension=new Dimension(Screen dimensions accordingly)
   Dimension Before_Maximising= Driver.manage().window().getSize();
   Logging.info("Before_Maximising"+Before_Maximising);
   if(Before_Maximising.equals(ExpectedDimension)) {
        Logging.info("Already maximised");
   }
    else {
    Driver.manage().window().setSize(ExpectedDimension);;
    Dimension After_Maximising = Driver().manage().window().getSize();
    Logging.info("After_Maximising"+After_Maximising);
    }
Dejy Joy
  • 11
  • 1
0

Had this same thing happen using Selenium 3.14.0, Chrome 70, Chromedriver 2.43.

The fix for me was the remove the --start-maximized flag from my chromeoptions, and after the browser is open have a call to a method that does:

    driver.manage().window().setPosition(new Point(0, 0));
    driver.manage().window().setSize(new Dimension(1920, 1080));

We're also running our remote automation in AWS EC2 containers running CentOS. In Windows and Mac the above flag had no issues when running locally.

Jim B
  • 1
0

For those facing this problem using Codeception, simply change window_size option to false.

- Webdriver:
   url: 'http://localhost/'
   window_size: false
CosetteN
  • 347
  • 1
  • 7
  • 18
0

I was facing the same problem with selenium 4.5.0 and was solved by updating to 4.9.0 (Chrome Version 112).

Pablo Guerrero
  • 936
  • 1
  • 12
  • 22