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.
Related
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 am unable to launch chrome (or any other browser) with selenium. The same code works when i run from my home PC. so i am thinking it has to do with firewall and security set up.
selenium version is 3.2, Chrome driver version is 2.28 i have also tried 2.25 (same error). the code used:
System.setProperty("webdriver.chrome.driver", "K://browserdriver//chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://google.com");
Error message:
Starting ChromeDriver 2.28.455520 (cc17746adff54984afff480136733114c6b3704b) on port 12121
Only local connections are allowed.
[0.023][SEVERE]: CreatePlatformSocket() returned an error: An invalid argument was supplied. (0x2726)
[0.023][SEVERE]: CreatePlatformSocket() returned an error: An invalid argument was supplied. (0x2726)
Port not available. Exiting...
Mar 11, 2017 9:13:06 PM org.openqa.selenium.os.UnixProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
FAILED CONFIGURATION: #BeforeTest beforeTest
org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '3.2.0', revision: '8c03df6b79', time: '2017-02-23 10:51:31 +0000'
System info: host: 'a1', ip: '', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_77'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:180)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:168)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:178)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:167)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:124)
at browesertest.NewTest.beforeTest(NewTest.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.TestRunner.beforeRun(TestRunner.java:641)
at org.testng.TestRunner.run(TestRunner.java:609)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
at org.testng.TestNG.run(TestNG.java:1031)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:24144/status] to be available after 20001 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:107)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:177)
... 32 more
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:140)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:80)
... 33 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(Unknown Source)
at com.google.common.util.c
I figured out the cause of the error; it is because my chromedriver.exe is on a networked drive and not on the machine the browser is running the test. Solution was to move chromedriver.exe under C drive.
I'm writing a Selenium script in Java. I've a website say originalwebsite.com, and when enter this and hit a go, it will go to authenticationwebsite.com, authenticate the credentials and auto redirect to originalwebsite.com.
I'm sorry that I can't reveal the origianlwebsite and authenticationwebsite URLs sine these are our Organisation's.
When I enter it directly in any Chrome browser, this is done automatically, since the authenticationwebsite credentials are stored.
But when i do it through Selenium, instead of redirecting to originalwebsite.com, the process stops at authenticationwebsite.com and asks for credentials. Going through some forums in SO, I've tried the below code.
In Chrome
System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
String user = System.getProperty("user.name");
// System.out.println(user);
ChromeOptions options = new ChromeOptions();
options.addArguments(
"user-data-dir=C:/Users/" + user.toUpperCase() + "/AppData/Local/Google/Chrome/User Data/Default");
options.addArguments("--start-maximized");
WebDriver cd = new ChromeDriver(options);
cd.get("https://originalwebsite.com");
When I run this i get the below Exception.
Starting ChromeDriver 2.19.346078 (6f1f0cde889532d48ce8242342d0b84f94b114a1) on port 9702
Only local connections are allowed.
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed
(Driver info: chromedriver=2.19.346078 (6f1f0cde889532d48ce8242342d0b84f94b114a1),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61.39 seconds
Build info: version: '2.48.1', revision: 'd80083d', time: '2015-10-08 21:07:25'
System info: host: 'U0138039-TPD-A', ip: '10.112.78.15', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_67'
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:647)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:148)
at EaselTest.main(EaselTest.java:21)
But in Firefox, this is working fine. And the code that i've used is as below.
ProfilesIni profile = new ProfilesIni();
FirefoxProfile ffprofile = profile.getProfile("default");
WebDriver cd = new FirefoxDriver(ffprofile);
cd.get("https://originalwebsite.com");
Please let me know how can i do it in Chrome, since most of the users here use chrome as their default browser.
Thanks
Seems like selenium is failing to pick up chrome browser where it is installed.
Check this answer : ChromeWebDriver - unknown error: Chrome failed to start: crashed
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