In this part, you will learn how to run your Selenium Test Scripts on Chrome Browser.
Chrome browser follows the WebDriver specification using an executable named ChromeDriver.exe. This executable begins a server on your machine which is in effect liable for running your Selenium test scripts.
Let's call a test case in which we'll attempt to simplify the following Google Chrome browser.
Our third test case will be built inside the same test suite (Demo_Test).
Step1. Right click on the "src" folder and create a new Class File from New > Class.
Offer your name of Class as "Third" and press the "Finish" button.
Step2. Open URL: https://sites.google.com/a/chromium.org/chromedriver/downloads in your browser.
Step 3. Click on the link called "ChromeDriver 2.41." It will lead you to the executables files directory at ChromeDriver. Update as per currently running operating system.
For windows, click on the "chromedriver_win32.zip" download.
The file that you access will be in zipped format. Unpack the contents in an correct directory.
Step 4. Set a "webdriver.chrome.driver" system property to the path of your ChromeDriver.exe file, and instant a ChromeDriver account.
Here is a sample code to do that.
// System Property for Chrome Driver System.setProperty("webdriver.chrome.driver","D:\\ChromeDriver\\chromedriver.exe"); // Instantiate a ChromeDriver class. WebDriver driver=new ChromeDriver();
Step 5. It is now time to write. For each block of code we've inserted comments to illustrate the steps clearly.
Step6. Right click on the Eclipse code and select Run As > Java Application.