How to Use Chrome for Running Webdriver Test Cases

Whether we are working on a Webdriver project or building an online sample for learning, it’s the Firefox browser we mostly use to run the test cases. But it’s also a fact that it fails quite often due to an incompatible version of the Selenium Jar. So the next best alternative is to use Chrome for running Webdriver test cases. Since you can use Firefox by merely adding the Selenium Jar, but you would need an additional driver module for Chrome to run test cases. Hence, in this tutorial, we thought to address this issue. So we came up with a practical example for running Webdriver test cases in Chrome. However, we’d recently done a post on the Selenium TestNG interview questions where we gave tips to solve a similar type of issues. So you might also like to read it to know about these problems and their solution.

Firefox failing to run Webdriver is real. Also, you must believe that it’s not an imaginary issue with Firefox. We’d ourselves faced it with Firefox v47.0.0 and Selenium Jar 2.53.0. You may even check it on the Stackoverflow site where people made queries asking for a solution. Nonetheless, this issue is now stand resolved in Firefox v47.0.1 and Selenium Jar 2.53.1. But this incident led us to choose Chrome for running Webdriver test cases.

As we already mentioned above that barring Firefox, Selenium requires other browsers to provide their driver modules for supporting Webdriver. These drivers are executable files which work as a server for the respective browser. Let’s now read follow up instructions to set up Chrome driver for running Webdriver tests.

How to Use Chrome for Running Webdriver Test Cases?

To run WebDriver in Chrome browser, we require <ChromeDriver> which is a separate executable that Selenium WebDriver uses to control Chrome. ChromeDriver gets support from the Chromium team. It’s a standalone server which implements the WebDriver’s wire protocol for Chromium.

1- How to set up Chrome driver in Selenium?

1.1- First of all, download the latest version of ChromeDriver server. You can download it by clicking the below link.

Download Latest Chrome Driver

1.2- You have to select the Chrome driver based on your working environment. If you are working on windows, then click on the <Chromedriver_win32.zip>. And save the downloaded file to your local machine.

1.3- Next, you’ve to set the property for Chrome driver in the WebDriver code. Here, you need to provide the location of the ChromeDriver executable. See the code given below.

Let’s see an example program written in Java. It’ll help you in running Webdriver test cases.

2- Example: Using Chrome to run Webdriver Tests.

In this example, the sample code would do the following.

1- While executing the below code, Google Home Page will get opened in Chrome browser.

2- Then, we’ll validate the page title in our example.

2.1- Sample code for Running Webdriver Test Cases.

2.2- Execution Summary.

After you run the above code, it should give you the following output. Please refer the below screenshot.

Running Webdriver Test Cases - Execution Report

Running Webdriver Test Cases – Execution Report.

 

Hopefully, you will also see the same results. If you fall into any runtime issues, then do write us for a solution.

If you want more of such posts like this “How to Use Chrome for Running Webdriver Test Cases“, then please visit here more often.

 

All the Best,

TechBeamers.

Leave a Reply


*