Saturday, January 3, 2015

Running Selenium Webdriver tests on Google Chrome browser

Few months back i had added the support to execute tests on Google Chrome browser in my github project https://github.com/lalit-k/selenium-java-tests , so i thought to write it down how you can do the same if needed in your project.

3 Simple steps to add Google Chrome support in Selenium Webdriver project:
  1. Download the ChromeDriver.exe , you can download the latest version from http://chromedriver.storage.googleapis.com/index.html for your target operating system.[download url may change, you can google latest if it changes]
  2. Extract the chromedriver.exe from the downloaded zip, and place in your project resources folder.
    Add Chromedriver.exe
  3. Now, go to the Driver file where you are initializing the ChromeDriver and add the below code line to initialize the ChromeDriver.

System.setProperty("webdriver.chrome.driver", <full system path of the chromedriver.exe. Example: c:\tests\resources\chromedriver.exe>);
WebDriver driver = new ChromeDriver();

Tip : you can use the "System.getProperty("user.dir");" to get the current working directory and then append the path to chromedriver.exe


System.getProperty("user.dir")


You can also view the complete code changes for your reference at https://github.com/lalit-k/selenium-java-tests/commit/01cda755f72918a417b7b0cded1b2db4c387eb70

No comments:

AWS Certified Solutions Architect Associate - AWS Introduction - Questions

All the Best !!! Show Result !! Try Again !! ×