Execute Test case on different browsers

In this section, we will discuss, how we will Execute Test case on different browsers. You may observe in the last section, we have used Mozilla Firefox driver to run our Selenium Test Script. You can design your script which should be run in Chrome, IE or Safari also. But for that you need to add the respective driver into your code.

Execute Test case on Chrome Browser

If you want to use Chrome browser to automate your script, then you need to download chrome drive. You can download chrome driver from https://chromedriver.chromium.org/downloads

Test case on different browsers

Click on the download link of the chrome driver and download zip file based on your OS. If you are using Windows, then download corresponding Windows Chrome WebDriver. Same as if you are using Mac then download MAC Chrome Driver. Same as Linux also.

Test case on different browsers

After downloading the chrome driver, save this file in Selenium folder. After that define setProperty by passing the driver path as parameter. This will help WebDriver to work with the Chrome Driver. setProperty will take 2 parameter to work with corresponding browsers. one is “webdriver.chrome.driver” and second is the path for the driver you have downloaded. Below is the syntax for setProperty.

System.setProperty("webdriver.chrome.driver","/path/to/chromedriver"); 

Execute Test case on IE Browser

Same as chrome browsers, we can execute Test case on IE Browsers also.

If you want to use IE browser to automate your script, then you need to download IE drive. You can download IE driver from https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver

Click on the download link and download zip file based on your OS. If you are using Windows, then download corresponding Windows IE WebDriver. Same as if you are using Mac then download MAC Chrome Driver. Same as Linux also.

After downloading the IE driver, save this file in Selenium folder. After that define setProperty by passing the driver path as parameter. This will help WebDriver to work with the IE Driver. setProperty will take 2 parameter to work with corresponding browsers. one is “webdriver.chrome.driver” and second is the path for the driver you have downloaded. Below is the syntax for setProperty.

Follow the same procedure to download Safari Driver(http://selenium-release.storage.googleapis.com/index.html?path=2.48/) to work with Safari browsers.

Leave a Reply

Your email address will not be published. Required fields are marked *