Tuesday, October 4, 2011

Running tests on Google Chrome using Webdriver

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:

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

41 comments:

  1. Your blog made my day dude..!! Thanks a million tonne !It was really helpful for me :)

    ReplyDelete
  2. 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/");


    }
    }

    ReplyDelete
    Replies
    1. @vikas- you need to use chromedriver and not chrome browser. Both are 2 different things.

      Delete
    2. ya. with chrome driver now it's working fine. thanks varun

      Delete
  3. dude, thank you so very much :)

    ReplyDelete
  4. 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.

    ReplyDelete
    Replies
    1. I think this problem comes when the code is unable to invoke the chrome browser.
      Try adding ChromeDriver.exe also to the path.

      Delete
    2. 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.

      Delete
    3. 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();


      Delete
  5. 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);
    }
    }

    ReplyDelete
    Replies
    1. You need to import ChromeDriver class into your code.

      Delete
  6. 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.

    ReplyDelete
    Replies
    1. 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.

      Delete
  7. setting the system property does't changes I given complete system path. I initialize the chrome driver but should not lunching to the chrome.

    ReplyDelete
  8. Hi varun

    can you tell me how to run our test on multiple browser instance parallel after setting up hub and node

    ReplyDelete
    Replies
    1. 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.

      Delete
  9. 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.

    ReplyDelete
  10. 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

    ReplyDelete
    Replies
    1. can you paste the command line that you are using to start the server.

      Delete
    2. 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

      Delete
    3. Change the path specified to :

      c:\\Users\\tia\\AppData\\Local\\Google\\Chrome\\Application\\chromedriver.exe

      Delete
    4. 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

      Delete
    5. Try putting it in the PATH variable and check. There may be some other problem also.

      Delete
    6. 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

      Delete
    7. 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

      Delete
  11. 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.

    ReplyDelete
    Replies
    1. 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");

      Delete
  12. 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)

    ReplyDelete
    Replies
    1. Check your libs and version of chromedriver and selenium driver

      Delete
  13. 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 .

    ReplyDelete
    Replies
    1. You can download it from following urls:

      https://code.google.com/p/selenium/wiki/ChromeDriver

      http://chromedriver.storage.googleapis.com/index.html

      Delete
  14. And finally somebody who post the complete solution. Thanks a lot man!

    ReplyDelete
  15. 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

    ReplyDelete
  16. 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?





    ReplyDelete
    Replies
    1. The exact error is
      java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property

      Delete
    2. well, got the answer, firefoxdriver is included in selenium-server-standalone while chromedriver is provided by chromium

      Delete
  17. This comment has been removed by the author.

    ReplyDelete
  18. 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.

    ReplyDelete