Google Chrome

Being one of the most popular web browsers in the world, Google Chrome is a must-have when talking about automated testing.Google_Chrome_icon

The Chrome Driver is easy to configure and use with Selenium WebDriver.

First of all, the driver must be downloaded from seleniumhq.org.

 

Set it up using the following class:

public void setupChromeDriver() {
 ChromeOptions co = new ChromeOptions();
 co.addArguments("--user-agent=" + prop.getProperty("userAgent"));
 DesiredCapabilities cap = DesiredCapabilities.chrome();
 cap.setCapability(ChromeOptions.CAPABILITY, co);
 System.setProperty("webdriver.chrome.driver", "...\\chromedriver.exe"); // driver location
 ChromeDriver cDriver = new ChromeDriver(cap);
 cDriver.manage().window().maximize();
 }

Key takeaways:

  • Default Chrome capabilities should be added.
  • A custom user agent can be set for the driver.

One Comment

  1. bogdandd May 29, 2016 Reply

Add a Comment

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