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:
Tip : you can use the "System.getProperty("user.dir");" to get the current working directory and then append the path to chromedriver.exe
You can also view the complete code changes for your reference at https://github.com/lalit-k/selenium-java-tests/commit/01cda755f72918a417b7b0cded1b2db4c387eb70
3 Simple steps to add Google Chrome support in Selenium Webdriver project:
- 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]
- Extract the chromedriver.exe from the downloaded zip, and place in your project resources folder.
Add Chromedriver.exe - 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:
Post a Comment