Selenium Tests failing on Chrome Version 111

HOME

UPDATE – 27/03/2023

Selenium Version – 4.8.3 has implemented the fix for Chrome Version 111. As per the below changelog, we don’t need to add “–remote-allow-origins=*”, if we are using Selenium Version – 4.8.3.

Selenium ChangeLog

Chrome Version 111 is recently released that has broken the Selenium Tests. In the current scenario, I’m using Selenium 4.8.0. You can see a simple Selenium test where we want to open a Chrome Browser and open Google.com failed.

import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.time.Duration;

public class ChromeTests {

    public static void main(String[] args) {

        WebDriverManager.chromedriver().setup();
        WebDriver driver = new ChromeDriver();
        driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(20));
        driver.get("https://www.google.com/");
        String PageTiltle = driver.getTitle();
        System.out.println("Page Title :"+PageTiltle);
        driver.close();
    }
}

The output of the above program is

Below is the screenshot of the Chrome Browser trying to open Google.com.

One of the solutions is to add “–remote-allow-origins=*” to ChromeOptions. The sample code is shown below:

import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import java.time.Duration;

public class ChromeTests {

    public static void main(String[] args) {

        ChromeOptions options = new ChromeOptions();
        options.addArguments("--remote-allow-origins=*");
        WebDriver driver = new ChromeDriver(options);
        driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(20));
        driver.get("https://www.google.com/");
        String PageTiltle = driver.getTitle();
        System.out.println("Page Title :"+PageTiltle);
        driver.close();
    }
}

By default, Selenium 4 is compatible with Chrome v75 and greater. 

The output of the above program is

Hopefully, this trick will help you in your automation journey.