ChromeDriver class is used to run the Selenium WebDriver Automation Tests on Google Chrome Browser.
Lets Implement This:
Pre-requisites:
1. Create a new Java Project say 'WebDriver-Project13' in Eclipse IDE
2. Configure the Project to work with Selenium WebDriver
3. Create a package say 'package13' under the newly created project.
4. Create a Java Class file say 'Class13' under the newly created package as shown below:
Actual Steps:
1. Write the following code into the newly created Java Class file as shown below and make sure that you resolve all the errors before going to next step:
2. Save and Run the 'Class13.java' file by selecting the 'JUnit Test' option and observe that the Test got failed with the following error as shown below:
3. Now in order to overcome this error, lets set the path to the driver executable by following the next steps.
4. Open https://code.google.com/p/chromedriver/downloads/list and download the chromedriver.exe by clicking on the chromedriver link as shown below:
5. Observe that 'ChromeDriver Server for windows 32 ' page will be displayed as shown below:
6. Find out the Chrome Browser versions which are supported by this ChromeDriver server as shown below and make sure that you have appropriate Chrome Browser version installed on your machine:
7. Now click on the Download link as shown below:
8. Observe that the ZIP file got downloaded as shown below:
9. Extract the ZIP file as shown below (I use WinRAR software for extracting the ZIP files):
10. Observe that chromedriver.exe file got extracted as shown below:
11. Copy the extracted chromedriver.exe file and paste it under the C drive of your computer as shown below:
12. Copy the statement System.setProperty("webdriver.chrome.driver", "path\\to\\chromedriver.exe"); and paste it to the setUp( ) method in our automation code as shown below:
13. Now replace the existing path with the path of the chromedriver.exe file which is under the C Drive on your machine as shown below:
14. Now Save and Run the 'Class13.java' file by selecting the 'JUnit Test' option and ensure that Selenium WebDriver Automation Test has Run in Chrome Browser as shown below:
Watch the below video:
Click here to watch the video.
Download this Project:
Click here to download this project and import into Eclipse IDE on your machine.
Please comment below to feedback or ask questions.
Using InternetExplorerDriver for Running our Tests on Internet Explorer Browser will be explained in the next post.