Chrome specific functionality

These are capabilities and features specific to Google Chrome browsers.

By default, Selenium 4 is compatible with Chrome v75 and greater. Note that the version of the Chrome browser and the version of chromedriver must match the major version.

Options

Capabilities common to all browsers are described on the Options page.

Capabilities unique to Chrome can be found at Google’s page for Capabilities & ChromeOptions

Starting a Chrome session with basic defined options looks like this:

        ChromeOptions options = new ChromeOptions();
        driver = new ChromeDriver(options);

Note that Python must specify service class to use Driver Manager

    service = ChromeService(executable_path=ChromeDriverManager().install())
    options = ChromeOptions()
    driver = webdriver.Chrome(options=options, service=service)
            var options = new ChromeOptions();
            var driver = new ChromeDriver(options);
    options = Selenium::WebDriver::Options.chrome
    @driver = Selenium::WebDriver.for :chrome, options: options
            let options = new chrome.Options();
            driver = await new Builder()
                .setChromeOptions(options)
                .forBrowser('chrome')
                .build();

Here are a few common use cases with different capabilities:

Arguments

The args parameter is for a list of Command Line Switches used when starting the browser. Commonly used args include --start-maximized and user-data-dir=/tmp/temp_profile

Add an argument to options:

Start browser in a specified location

The binary parameter takes the path of an alternate location of browser to use. With this parameter you can use chromedriver to drive various Chromium based browsers.

Add a browser location to options:

Add extensions

The extensions parameter accepts crx files

Add an extension to options:

Keeping browser open

Setting the detach parameter to true will keep the browser open after the driver process has been quit.

Ad a binary to options:

Excluding arguments

Chrome adds various arguments, if you do not want those arguments added, pass them into excludeSwitches. A common example is to turn the popup blocker back on.

Set excluded arguments on options:

Casting

You can drive Chrome Cast devices, including sharing tabs

Network conditions

You can simulate various network conditions.

Logs

Permissions

DevTools

See the Chrome DevTools section for more information about using Chrome DevTools