How to run Selenium tests on Chrome Browser using?

SeleniumAutomation TestingTesting Tools

We can run Selenium tests on Chrome browser with the help of the chromedriver.exe executable file. First, we have to download the chromedriver.exe file from the following link −

We have to click on the link which matches with the Chrome browser in our system. Next, choose the link based operating system (Windows, Linux or Mac) we are presently using.

Once the download has completed, a zip file gets created. We have to extract the zip file and store the chromedriver.exe file in a desired location. Then, we have to configure the path of the chromedriver.exe file using the System.setProperty method along with creating an object of the ChromeDriver class.


import org.openqa.selenium.WebDriver;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class ChromeBrwLaunch{
   public static void main(String[] args) {
      //configure chromedriver.exe path
      //object of ChromeDriver
      WebDriver driver = new ChromeDriver();
      //launch URL
      // get browser name
      Capabilities cap = ((RemoteWebDriver) driver).getCapabilities();
      System.out.println("Browser: " + cap.getBrowserName());


Published on 06-Apr-2021 13:50:54