Starting ChromeDriver 80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987#{#882}) on port 37201
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 80
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'DELL', ip: '192.168.43.201', os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2', java.version: '1.8.0_221'
Driver info: driver.version: ChromeDriver
remote stacktrace: Backtrace:Ordinal0 [0x01510C83+1707139]
Ordinal0 [0x014768F1+1075441]
Ordinal0 [0x013EDFC9+516041]
Ordinal0 [0x01380554+66900]
The version of google chrome browser on your system should be same as your chrome driver version.
Goto Google Chrome -> Help -> About Google Chrome to check chrome version.
Then download the same version chromedriver from here: https://chromedriver.chromium.org/downloads
I have recently updated ChromeDriver to 2.36 after chrome was auto updated to v65.
But on running test now i am getting below exceptions
Starting ChromeDriver 2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91) on port 10482
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: failed to write automation extension zip
(Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 218 milliseconds
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: '172.16.27.222', ip: '172.16.123.114', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77'
Driver info: driver.version: ChromeDriver
Have tried both chromeOptions & DesiredCapabilties
ChromeOptions o = new ChromeOptions();
o.addArguments("disable-extensions");
o.addArguments("--start-maximized");
ChromeDriver chromeDriver = new ChromeDriver(o);
return chromeDriver;
Also tried below method :
ChromeDriver chromeDriver = new ChromeDriver(capabilities);
chromeDriver.manage().window().maximize();
The error says it all :
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: failed to write automation extension zip
(Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 218 milliseconds
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: '172.16.27.222', ip: '172.16.123.114', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77'
Driver info: driver.version: ChromeDriver
It is clear from your error stack trace that the driver.version is not getting recognized.
Your main issue is the version compatibility between the binaries you are using as follows :
You are using chromedriver=2.36
You are using chrome=65.0 (as per your question)
You are using Selenium Client v3.11.0
Your JDK version is 1.8.0_77 which is pretty ancient.
So there is a clear mismatch between the JDK v8u77 , Selenium Client v3.11.0 , ChromeDriver version (v2.36) and the Chrome Browser version (v65.0)
Solution
Upgrade JDK to recent levels JDK 8u162.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
If your base Chrome version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Chrome.
Execute your #Test.
Additional Considerations
If you intend to use ChromeDriver and Chrome Browser, while initializing the WebDriver instance instead of using the ChromeDriver implementation use the WebDriver interface as follows :
WebDriver chromeDriver = new ChromeDriver(o);
If you intend to maximize the browser window, instead of using chromeDriver.manage().window().maximize(); use the ChromeOptions instance as follows :
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
Here are the arguments I use:
ArrayList<String> args = new ArrayList<String>();
args.add("enable-automation");
args.add("test-type=browser");
args.add("disable-plugins");
args.add("disable-infobars");
args.add("disable-extensions");
options.put("args", args);
I think you need to at least add the "enable-automation" argument.
I recently upgraded my chrome version to 60 and chromedriver to version 2.31. Post that I have started getting the following exception when I try to do a maximize of the browser window.
driver.driver.manage().window().maximize()
org.openqa.selenium.WebDriverException: unknown error: failed to
change window state to maximized, current state is normal (Session
info: chrome=60.0.3112.78) (Driver info: chromedriver=2.31.488763
(092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Linux
4.2.0-27-generic x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 108 milliseconds
Build info: version: '2.53.1', revision:
'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30
19:26:09' System info: host: 'bb-blr-prod-stage-stg1-01', ip:
'10.3.211.2', os.name: 'Linux', os.arch: 'amd64', os.version:
'4.2.0-27-generic', java.version: '1.7.0_80' Session ID:
c7de7149dd490cc7760d2f4fc49f0325 Driver info:
org.openqa.selenium.chrome.ChromeDriver Capabilities [{platform=LINUX,
acceptSslCerts=true, javascriptEnabled=true, browserName=chrome,
chrome={userDataDir=/tmp/.org.chromium.Chromium.WABPhO,
chromedriverVersion=2.31.488763
(092de99f48a300323ecf8c2a4e2e7cab51de5ba8)},
networkConnectionEnabled=false, unexpectedAlertBehaviour=,
rotatable=false, setWindowRect=true, locationContextEnabled=true,
mobileEmulationEnabled=false, pageLoadStrategy=normal,
version=60.0.3112.78, takesHeapSnapshot=true,
cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true,
browserConnectionEnabled=false, webStorageEnabled=true,
nativeEvents=true, hasTouchScreen=false,
applicationCacheEnabled=false, takesScreenshot=true}]
I run my tests in headless mode using ChromeDriver on Geb.
Chrome version - 60.0.3112.78
chromedriver version - 2.31.488763
OS - Ubuntu 14.04.4 LTS
Selenium version - 2.53.1
WebDriver Language Bindings
Geb - 0.13.1
Since you're running tests in a headless mode, there is no active browser window available. As such your
driver.driver.manage().window().maximize()
would always fail in such situations because the driver doesn't know which window to maximize since there aren't any available.
You can either follow what #DebanjanB has mentioned or you can start the headless browser with a specific screen size like 1440x900 etc, doing something like this
driver.manage().window().setSize(new Dimension(1440, 900));
[Edit] In most cases now that I've seen that the maximize() method works in headless too - however I've not tested this on a CI system.
Add below ChromeOption in your code :
options.addArguments("--window-size=1325x744");
Also refer this blog for more
This is an open bug (follow here) : https://bugs.chromium.org/p/chromedriver/issues/detail?id=1901
There seems to be a minor discrepancy in the line of code:
driver.driver.manage().window().maximize()
You need to replace this line of code with:
driver.manage().window().maximize()
In case this solution doesn't address your issue, to use Google Chrome in headless you can use either of the following solutions:
Using start-maximized
It is recommended to maximize the Google Chrome browser through ChromeOptions class as follows:
Code Block:
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
options.addArguments("--headless");
options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
options.setExperimentalOption("useAutomationExtension", false);
WebDriver driver = new ChromeDriver(options);
driver.get("https://www.google.com/");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File(".\\Screenshots\\using-start-maximized.png"));
driver.quit();
Browser Snapshot:
Using --window-size=1400,600
As an alternative you can also add the argument for the expected window size as follows:
Code Block:
ChromeOptions options = new ChromeOptions();
options.addArguments("--window-size=1400,600");
options.addArguments("--headless");
options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
options.setExperimentalOption("useAutomationExtension", false);
WebDriver driver = new ChromeDriver(options);
driver.get("https://www.google.com/");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File(".\\Screenshots\\using-window-size.png"));
driver.quit();
Browser Snapshot:
Using setSize(new Dimension(1440, 900))
Code Block:
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless");
options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
options.setExperimentalOption("useAutomationExtension", false);
WebDriver driver = new ChromeDriver(options);
driver.get("https://www.google.com/");
driver.manage().window().setSize(new Dimension(1440, 900));
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File(".\\Screenshots\\using-setSize.png"));
driver.quit();
Browser Snapshot:
tl; dr
You can find Selenium python client based discussion on maximizing window in Selenium Firefox headless returns different results
I'm using chromedriver 2.30 & chrome browser v60 through protractor. I run the tests headless too albeit I don't do it via chromeoptions. Rather I run tests headless using xvfb-run on a unix distribution. I'm encountering this issue also albeit it fails randomly for me. See stack below
[chrome #11] [31mWebDriverError: unknown error: failed to change window state to maximized, current state is normal
[chrome #11] (Session info: chrome=60.0.3112.78)
[chrome #11] (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 3.10.0-514.26.2.el7.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
[chrome #11] Command duration or timeout: 122 milliseconds
[chrome #11] Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
[chrome #11] System info: host: 's1wfadvcilvm08', ip: '172.16.184.183', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-514.26.2.el7.x86_64', java.version: '1.8.0_141'
[chrome #11] Driver info: org.openqa.selenium.chrome.ChromeDriver
[chrome #11] Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57), userDataDir=/tmp/.org.chromium.Chromium.BNsN1w}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=60.0.3112.78, platform=LINUX, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=}]
My code at the beginning of each test does the following
browser.manage().window().maximize();
changing to
driver.driver.manage().window().maximize();
driver.manage().window().maximize();
doesn't work for me either unfortunately. Shouldn't browser.manage().window().maximize() be still working as I'm running headless using xvfb-run rather than doing headless via chrome options?
This bug was initially fixed in ChromeDriver 2.42, and was actual for macOS until 2.44 (check changelogs: http://chromedriver.chromium.org/downloads).
So there is a solution for everyone who faces this issue: update your driver version
This is known issue on Ubuntu 20.04 LTS for headless Google Chrome. I just used Java's awt pakage to get maximum resolution of whatevevr screen i.e. xvbf for Ubuntu LTS and current screen for Windows 10 and set it in arggument of ChromeOption to configure Webdriver
java.awt.Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
chromeOptions.addArguments("--window-size=" + (int) screenDimension.getWidth() + "," + (int) screenDimension.getHeight());
I get the following error while launching chrome driver. Any suggestions?
package packag;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Demo2
{
public static void main (String [] args)
{
System.setProperty("webdriver.chrome.driver","C:/chromedriver.exe");
WebDriver driver= new ChromeDriver();
driver.get("http://www.google.com");
driver.close();
}
}
Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 26665
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.2
x86_64) (WARNING: The server did not provide any stacktrace
information)
Command duration or timeout: 754 milliseconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'Vishak', ip: '192.168.0.23', os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2', java.version: '1.8.0_25'
Driver info: org.openqa.selenium.chrome.ChromeDriver at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
Source) at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source) at java.lang.reflect.Constructor.newInstance(Unknown Source)
at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at
org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
at
org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:144)
at
org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:170)
at
org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:159)
at
org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:116)
at packag.Demo2.main(Demo2.java:11)
Install Chrome on the machine running your code.
It is due to ChromeDriver and Chrome Browser incompatibility. Either you need to update ChromeDriver or vice verse. I would recommend installing updated versions of both on safer side.
Make sure you have latest chromedriver.exe and placed it under C:/chromedriver.exe directory.
If not please download the same from here and place it in specified directory.
I was able to reproduce the issue by placing the wrong executable. so you can
download the correct executable for your platform.
you may want to place the driver executable somewhere other than the "c" drive.
may be documents directory for your user, or create a directory in your project
and refer from there.
Please see my grid batch file. (I added both chrome binary and chrome driver location in my path)
My code works perfectly if I use firefox but for chrome and IE it throws an Exception given below. I am sure I am missing a very trivial thing but I am not able to figure it out.
Batch file
set HERE=C:\Users\Administrator\Downloads
set JAVA_HOME=%HERE%\jdk-7u13-windows-x64
set PATH=%JAVA_HOME%\jre\bin;%JAVA_HOME%\bin;%CHROME_DRIVER_LOC%;%IE_DRIVER_LOC%;%CHROME_BINARY_LOC%;%PATH%;
set SELENIUM_VERSION=2.29.0
set CHROME_VERSION=chromedriver_win_26.0.1383.0
set HUB_URL=http://localhost:4444/grid/register
set CHROME_DRIVER_LOC=C:\Users\Administrator\Downloads\chromedriver_win_26.0.1383.0\chromedriver.exe
set IE_DRIVER_LOC=C:\Users\Adminstrator\Downloads\IEDriverServer_x64_2.31.0\IEDriverServer.exe
set CHROME_BINARY_LOC=C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe
start java -jar selenium-server-standalone-2.29.0.jar -role hub
start java -jar selenium-server-standalone-2.29.0.jar -role node
-Dwebdriver.chrome.driver=%CHROME_DRIVER_LOC% -hub %HUB_URL% -port 5556
My sample code:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
URL url = new URL(“<http://localhost:4444/wd/hub>”);
WebDriver driver = new RemoteWebDriver(url, capabilities);
// And now use this to visit Google
driver.get(“web page”);
Exception I am getting :
Exception in thread “main” org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromedriver/downloads/list
Command duration or timeout: 608 milliseconds
Build info: version: ’2.29.0′, revision: ’58258c3′, time: ’2013-01-17 22:47:00′
System info: os.name: ‘Windows Server 2008 R2′, os.arch: ‘amd64′, os.version: ’6.1′, java.version: ’1.7.0_13′
Driver info: org.openqa.selenium.remote.RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:187)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:533)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:111)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:129)
at test.Test.main(Test.java:32)
Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see ….
Please help! I couldn’t understand what I am doing wrong. I have been struggling with this from quite some time now. Any help will be very much appreciated.
Thanks
Sushmita
I think, the below line is the culprit
start java -jar selenium-server-standalone-2.29.0.jar -role node
-Dwebdriver.chrome.driver=%CHROME_DRIVER_LOC% -hub %HUB_URL% -port 5556
Use below line and check if it is working.
start java -Dwebdriver.chrome.driver=%CHROME_DRIVER_LOC% -jar selenium-server-standalone-2.29.0.jar -role webdriver -hub %HUB_URL% -port 5556
With Chrome and IE, you will need to define a driver executable path, you can fine the files here:
http://code.google.com/p/chromedriver/downloads/list
and http://code.google.com/p/selenium/downloads/list
Then you will need something like this before you create a new ChromeDriver:
String chromeDriverPath = "C:\ChromeDriver.exe";
System.setProperty("webdriver.chrome.driver", chromeDriverPath);
A very simple workaround is to place the IEDriverServer and the chromedriver executables in the same folder as your selenium jar file