Tuesday, October 4, 2011
While automating your web-application using webdriver, many may have faced problems in executing your cases on Google-chrome. Whenever you try to use webdriver object for executing your cases on chrome using the following code:
you most probably get the following error:
Method - 1:
Start the selenium server using the following command:
DesiredCapabilities capability = DesiredCapabilities.chrome();
you most probably get the following error:
The path to the chromedriver 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/chromium/downloads/list
The solution to this error that has been mentioned in the given URL "http://code.google.com/p/selenium/wiki/ChromeDriver" is to set the chromedriver path to the variable "webdriver.chrome.driver". But how exactly to set the path and use it for your test execution is not given there. So I though to just document it here on my blog.
For setting the "webdriver.chrome.driver" value and for using google-chrome to execute your automated tests, you can use one of the following methods:
Method - 1:
Start the selenium server using the following command:
java -Dwebdriver.chrome.driver=/path/to/chromedriver -jar selenium-server-standalone-2.7.0.jar
And in your Java code you use the chrome driver in the following way:
DesiredCapabilities capability = DesiredCapabilities.chrome();
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
The advantage of using this method is that you can execute your test-cases in a remote machine and this is advantageous when you want to run it on grid.
Method - 2:
Set the system property "webdriver.chrome.driver" using System.setProperty() in your code and then try to execute your cases on Chrome.
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
WebDriver driver = new ChromeDriver();
This method works well when your tests are getting execute on a local machine and you are not starting any selenium server.
Following are some important links for Chrome driver:
Webdriver Chromedriver page:
http://code.google.com/p/selenium/wiki/ChromeDriver
ChromeDriver download page for downloading the ChromeDriver server:
http://code.google.com/p/chromium/downloads/list
Subscribe to:
Post Comments
(
Atom
)
44 comments :
Your blog made my day dude..!! Thanks a million tonne !It was really helpful for me :)
Thanks @Vasu
I am getting following error while using chrome browser:
[TestNG] Running:
C:\Users\Admin\AppData\Local\Temp\testng-eclipse-995334387\testng-customsuite.xml
[5396:5276:14390343:ERROR:extension_error_reporter.cc(56)] Extension error: Expected version "1.8", but version was "5.0.1701".
FAILED: f
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 17:28:14'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_07'
Driver info: driver.version: ChromeDriver
My code is as follows:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class chrome {
@Test
public void f() {
System.setProperty("webdriver.chrome.driver", "C:/Users/Admin/AppData/Local/Google/Chrome/Application/chrome.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.co.in/");
}
}
@vikas- you need to use chromedriver and not chrome browser. Both are 2 different things.
ya. with chrome driver now it's working fine. thanks varun
dude, thank you so very much :)
Welcome :)
Thanks man!!
Hi Varun,
Iam trying to invoke chrome browser using webdriver in my mac.
System.setProperty("webdriver.chrome.driver", "/Users/myname/Documents/New/chromedriver");
WebDriver driver = new ChromeDriver();
but on running gives following error as :
dyld: unknown required load command 0x80000022
FAILED: testGoogleSearch
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:09:54'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.5.8', java.version: '1.6.0_26'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:493)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:182)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:110)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:114)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:165)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:107)
at com.selenium.training.Firstprograms.testGoogleSearch(Firstprograms.java:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
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:1197)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1122)
at org.testng.TestNG.run(TestNG.java:1030)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:09:54'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.5.8', java.version: '1.6.0_26'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:166)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:62)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)
... 30 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:10837/status] to be available after 20019 ms
can u let me know where am getting wrong.
Hi Varun,
Thanks for posting this.
I'm still getting an issue I cannot understand...
"ChromeDriver cannot be resolved to a type"
Any help would be greatly appreciated.
Thanks
import org.junit.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
import java.io.File;
import java.util.Dictionary;
public class testchapter6 {
WebDriver driver;
//System.setProperty("webdriver.chrome.driver", "C:/Users/kmcdonnell/Desktop\\Work\\testing\\Selenium\\chromedriver_win_23.0.1240.0");
@Before
public void setUp(){
System.setProperty("webdriver.chrome.driver", "C:\\Windows\\chromedriver.exe)");
driver = new ChromeDriver(); //we will update this part with each section
driver.get("http://book.theautomatedtester.co.uk/chapter4");
}
@After
public void tearDown(){
driver.quit();
}
@Test
public void testExamples(){
WebElement element = driver.findElement(
By.id("selectLoad"));
String value = element.getAttribute("value");
Assert.assertEquals("Click to load the select below",
value);
}
}
You need to import ChromeDriver class into your code.
I think this problem comes when the code is unable to invoke the chrome browser.
Try adding ChromeDriver.exe also to the path.
Hi Varun,
I did also added ChromeDriver.exec as in Mac OS shows exec and even den shows the same error. Do i need to place the ChromeDriver in same path as where Chrome is installed and even doing that hasnt resolved the problem.
I have another issue in Firefox and using the link (http://www.deal4loans.com/home-loans.php ) where am not getting count of items from the drop down list (City) . it shows count as 0.
but selection it does selecting any one item , but trying to get count and to display list items from drop down list shows as 0.
can you let me know the java code i need to use to get the ist of counts.
i have used xpath and driver.findelements(By) and used a variable to as a.size() and used forloop but still shows count as 0.
I dont see and .exec extension for ChromeDriver for mac downloaded from here:
http://code.google.com/p/chromedriver/downloads/detail?name=chromedriver_mac_23.0.1240.0.zip&can=2&q=
For the drop down check your locator.The following should work:
driver.findelements(By.css("#City > option")).size();
Hi Varun,
Iam trying to chrome browser using webdriver in my windows
System.setProperty("webdriver.chrome.driver","C:\\workspace")
but some error displayed
that is
java.lang.IllegalStateException: 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
at com.google.common.base.Preconditions.checkState(Preconditions.java:176)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:105)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:69)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:107)
at test12.test123.setUp(test123.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
can u pl z let me known where am getting wrong.
At what point you are setting the system property. Hopefully its before initialize the driver object.
If you are doing the above try putting the complete path of the chromedriver to the system path.
setting the system property does't changes I given complete system path. I initialize the chrome driver but should not lunching to the chrome.
Hi varun
can you tell me how to run our test on multiple browser instance parallel after setting up hub and node
This depends on which execution framework you are using junit2, junit4 or testng. You can refer to my post :
http://blog.varunin.com/2011/10/selenium-grid-with-webdriver.html
Let me know if you have further issues.
Dear Mr.Varun,
I am able to open the browser and type into the fields but am not able to use the .click() command. I am suspecting a compatibility issue. Can you tell me which version of chrome and which version of chromedriver you are using.
Hi Varun,
Thanks for the post. I am using your method 1 via giving the chromedrive exe path while starting the hub and node on remote machine and m using thos code for calling chrome
public void initialize(final Browser browser) {
LOGGER.debug("Browser choice is [{}]", browser.name());
final RunMode runMode = (RunMode)properties.get(DefaultProperties.RUN_MODE);
final String remoteSeleniumHubUrl = properties.getProperty(DefaultProperties.REMOTE_SELENIUM_HUB_URL);
if (RunMode.REMOTE.equals(runMode) && !StringUtils.isEmpty(remoteSeleniumHubUrl)) {
LOGGER.debug("Creating remote driver. Browser choice is [{}], Hub Url is [{}]", browser, remoteSeleniumHubUrl);
delegate = createRemoteDriver(browser, remoteSeleniumHubUrl);
} else if (RunMode.LOCAL.equals(runMode)) {
LOGGER.debug("Creating local driver. Browser choice is [{}]", browser);
delegate = createLocalDriver(browser);
} else {
LOGGER.debug("Creating local driver. Browser choice is [{}]", browser);
delegate = createLocalDriver(browser);
}
}
private ThreadLocal createRemoteDriver(final Browser browser, final String remoteSeleniumHubUrl) {
final ThreadLocal webDriver = new ThreadLocal();
final DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setJavascriptEnabled(true);
switch (browser) {
case CHROME:
desiredCapabilities.setBrowserName("chrome");
desiredCapabilities.setCapability("chrome.switches", Arrays.asList("--no-sandbox"));
break;
try {
final URL url = new URL(remoteSeleniumHubUrl);
webDriver.set(new RemoteWebDriver(url, desiredCapabilities));
} catch (final MalformedURLException e) {
LOGGER.error("", e);
}
return webDriver;
}
But still I am getting the same error
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
Can you please help me
can you paste the command line that you are using to start the server.
Hi Varun,
I am using these comments for hub and nodes on remote machine -
java -DwebDriver.chrome.driver=c:/Users/tia/AppData/Local/Google/Chrome/Application/chromedriver.exe -jar selenium-server-standalone-2.31.0.jar -role hub
and for nodes
java -DwebDriver.chrome.driver=c:/Users/tia/AppData/Local/Google/Chrome/Application/chromedriver.exe -jar selenium-server-standalone-2.31.0.jar -role webDriver -hub http://localhost:4444
Change the path specified to :
c:\\Users\\tia\\AppData\\Local\\Google\\Chrome\\Application\\chromedriver.exe
Hi Varun,
I did try this (c:\\Users\\tia\\AppData\\Local\\Google\\Chrome\\Application\\chromedriver.exe), but i am getting the same error.
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
Please let me whts wrong here.Thanks
Try putting it in the PATH variable and check. There may be some other problem also.
Hi Varun,
While running my test in Chrome I am getting below error. My Chrome is installed in the following path: C:\Program Files (x86)\Google\Chrome\
My code is
@Test
public void setUp() throws Exception {
System.setProperty("webdriver.chrome.driver", "C:/chromedriver.exe");
driver = new ChromeDriver();
/*Script*/
}
"org.openqa.selenium.WebDriverException: java.io.IOException: Cannot run program "C:\Users\jkgupta\Local Settings\Application Data\Google\Chrome\Application\chrome.exe": CreateProcess error=2, The system cannot find the file specified
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0'
Driver info: driver.version: chrome
at org.openqa.selenium.chrome.ChromeBinary.start(ChromeBinary.java:55)
at org.openqa.selenium.chrome.ChromeDriver.startClient(ChromeDriver.java:75)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:50)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:60)
at creatematter.Add_Matter.setUp(Add_Matter.java:33)
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:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
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:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: java.io.IOException: Cannot run program "C:\Users\jkgupta\Local Settings\Application Data\Google\Chrome\Application\chrome.exe": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at org.openqa.selenium.chrome.ChromeBinary.start(ChromeBinary.java:41)
... 28 more
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 30 more"
Pl. help me on this.
Its already there in the path variable (both ob my local and vm). locally its working fine but giving the above error when i am trying to run my test on remote vm
Hi jay,
TRY THIS. Give the actual path of chrome driver in the test
@Test
public void setUp() throws Exception {
System.setProperty("webdriver.chrome.driver", "C:/Program Files (x86)/Google/Chrome/chromedriver.exe");
Hi,
I am able to execute on vm, below is command is used.
java -Dwebdriver.chrome.driver=C:/chromedriver.exe -jar selenium-server-standalone-2.32.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 5555 -browser browserName=chrome
Hi,
I am using the below code:
System.setProperty("webdriver.chrome.driver", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver-win.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com/");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("mysql excel 2013");
element.submit();
Chrome :29
ChromeDriver:win32 latest
kindly help to resolve this as after execution am getting the error:
Starting ChromeDriver (v2.2) on port 47525
log4j:WARN No appenders could be found for logger (org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.openqa.selenium.WebDriverException: chrome not reachable
(Driver info: chromedriver=2.2,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 28.67 seconds
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 16:53:24'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_23'
Driver info: driver.version: ChromeDriver
Session ID: 3655d6ab20ebadd9e0e0637aa9acd4a9
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:188)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:155)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:107)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:165)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:107)
at testNG.testChrome.main(testChrome.java:25)
Check your libs and version of chromedriver and selenium driver
HI Varun ,
From where can i download the latest version of Chrome Driver . Can you please share the link for the same , I tried to find in the Internet but i am not able to find the proper one .
You can download it from following urls:
https://code.google.com/p/selenium/wiki/ChromeDriver
http://chromedriver.storage.googleapis.com/index.html
And finally somebody who post the complete solution. Thanks a lot man!
HI,
I'm trying to start a add on on a chrome browser with the URL of the add on.But when I try to launch the add on using webdriver, I get the message: "This Webpage cannot be found"
Can any one let know how can I launch the add on using webdriver?
Regards
Tejesh
Hi Varun, hope you can help me. I am using maven to resolve dependencies and my pom looks like this:
org.testng
testng
6.8.5
org.seleniumhq.selenium
selenium-server
2.41.0
This downloads all the jars for me (selenium-chrome-driver-2.41.0.jar, selenium-firefox-driver-2.41.0 everything) and places them in ~/.m2/repository/org/seleniumhq/selenium/selenium-server/2.41.0/ (I am using mac). It also adds them to my library so that I don't have to download them manually and manage them.
Now when I run my tests on firefox using following code:
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
driver = new FirefoxDriver(capabilities);
the tests run fine on firefox
However if I try to use similar code for chrome
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
WebDriver driver = new ChromeDriver(capabilities);
it starts giving same error as you mentioned. My question is if I did not have to provide path to firefox driver then why I have to provide the path to chrome driver?
The exact error is
java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property
well, got the answer, firefoxdriver is included in selenium-server-standalone while chromedriver is provided by chromium
Thanks Varun, it worked for me too..
To be more specific, Chrome exe no longer exists now in "C:\Users\\AppData\Local\Google\Chrome\Application" path, so creating a shortcut and placing it at this location resolved my issue.
Hi Varun,
Could you please let us know how we can set the chrome browser in the Selenium webdriver.
as we are creating the project using maven.
Please please send us a sample code.
Our code is :
Pom.xml:
project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.netapp.selenium
seleniumwebdriver
0.0.1-SNAPSHOT
seleniumwebdriver
Testing project
org.seleniumhq.selenium
selenium-java
2.42.2
junit
junit
4.4
org.seleniumhq.selenium
selenium-chrome-driver
2.42.2
===============================================================
Code:
package com.netapp.webdriver;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Demo {
public static void main(String[] args) {
System.setProperty("webdriver.chorme.driver","C:\\Users\\pankaj.asegaonkar\\Downloads\\chromedriver_win_26.0.1383.0\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("http://www.google.co.in");
actual result: we are able to open the chrome browser but url is not getting called.
Please let us know what is wrong with the code.
Hi Varun,
Iam trying to chrome browser using webdriver in my windows
System.setProperty("webdriver.chrome.driver", "C:/Selenium/Chrome/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
but some error displayed
that is
Starting ChromeDriver (v2.11.298604 (75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e)) on port 16666
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed
(Driver info: chromedriver=2.11.298604 (75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e),platform=Windows NT 6.1 SP1 x86) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61.36 seconds
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03'
System info: host: 'N3WS0014-HP', ip: '192.168.100.89', 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:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:139)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:171)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:160)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:117)
at Sample.main(Sample.java:14)
thanks a lot.. it soved my problem
Post a Comment