How To Run Test Cases Using Google Chrome In Selenium Automation Script

To run google chrome in your selenium webdriver automation script is similar to the IE Driver server, you need a ChromeDriver executable file also. The theory is the same as IE, this driver also startup a server, and waiting to run the selenium commands come from the selenium webdriver scripts.

1. How To Download The Correct Google ChromeDriver Version.

Download the google ChromeDriver version that matches your google chrome version from the URL

If the google ChromeDriver version does not match Google Chrome version, when you run your selenium program, it will popup below error message.

Starting ChromeDriver 88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324@{#1784}) on port 7316
Only local connections are allowed.
Please see for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 88
Current browser version is 90.0.4430.85 with binary path /Applications/Google Chrome

Click the google chrome Customize and control Google Chrome( 3 vertical dots on the top right corner ) —> Help —> About Google Chrome menu item to get the google chrome version.

My google chrome version is 90, and I run google ChromeDriver on macOS, so my download version is 90.0.4430.24/

Save the download file to somewhere and unzip it to get the ChromeDriver executable file. In my macOS, the ChromeDriver executable file saved path is /Users/songzhao/Documents/WorkSpace/Tools/chromedriver.

2. How To Use Google ChromeDriver To Launch Google Chrome Web browser.

You need two steps in your java code to start the google chrome web browser with ChromeDriver. Set system property‘s value to your downloaded ChromeDriver executable file path.

Create an instance of the Google ChromeDriver class. Below is the example source code.


import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class ChromeBasic {
    public static void StartChrome() {
        try {
            // Set the geckodriver.exe path to the system property webdriver.gecko.driver's value.
            System.setProperty("", "/Users/songzhao/Documents/WorkSpace/Tools/chromedriver");
            //Create Firefox webdriver instance and launch Firefox browser. 
            WebDriver chromeDriver = new ChromeDriver(); 
            //Maxmize Firefox browser window 
            //Browse google home page. You should add http:// or https:// protocal before otherwise there will have an exception occured
            //Sleep 2 seconds to wait for the page load complete
            // Get the google search box object by the search box name.
            WebElement searchBox = chromeDriver.findElement("q"));
            // Input search keyword text in the google search box.
            // Press the keyboard Enter key to close the search tips drop-down list and search.
            // Get the google search button by the search button name.
            // WebElement searchBtn = ffDriver.findElement("btnK"));
            // Click the search button to search.
            //Print out action success message.
            System.out.println("Open website success.");
            //Sleep 10 seconds to wait for the page load complete
            // Quit and close the Firefox web browser.
        }catch(Exception ex){

    public static void main(String[] args) {




When you use any web browser (chrome, IE or Firefox) to browse a web page in selenium webdriver you need to add http:// or https:// before the domain name, otherwise the org.openqa.selenium.InvalidArgumentException: invalid argument exception will be thrown.

Starting ChromeDriver 90.0.4430.24 (4c6d850f087da467d926e8eddb76550aed655991-refs/branch-heads/4430@{#429}) on port 35769
Only local connections are allowed.
Please see for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Apr 26, 2021 9:47:59 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
org.openqa.selenium.InvalidArgumentException: invalid argument
  (Session info: chrome=90.0.4430.85)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'songs-MacBook-Pro.local', ip: '', 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.7', java.version: '12.0.1'
Driver info:
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 90.0.4430.85, chrome: {chromedriverVersion: 90.0.4430.24 (4c6d850f087da..., userDataDir: /var/folders/qr/mrbn885s649...}, goog:chromeOptions: {debuggerAddress: localhost:52628}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Session ID: 02d8e832f77c1f028784e360b5a22f04
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(
    at java.base/java.lang.reflect.Constructor.newInstance(
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(
    at org.openqa.selenium.remote.RemoteWebDriver.execute(
    at org.openqa.selenium.remote.RemoteWebDriver.get(

3. References.

How To Create Maven Project In Eclipse

How To Add Selenium Server Standalone Jar File Into Your Java Project

How To Use Firefox Webdriver To Launch Firefox Browser Automatically In Java.

How To Run Test Cases Using Apple Safari In Selenium Automation Script.

How To Run Microsoft Internet Explorer And Edge In Selenium Webdriver Automation Script.

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.