0

After updating Google Chrome and Selenium, tests are not running with ChromeDriver.

System:

OS: Ubuntu 20.04.5 LTS
Selenium: selenium-server-4.8.1.jar
Chrome: Version 111.0.5563.64 (Official Build) (64-bit)
Java: 
openjdk version "1.8.0_362"
OpenJDK Runtime Environment (build 1.8.0_362-8u362-ga-0ubuntu1~20.04.1-b09)
OpenJDK 64-Bit Server VM (build 25.362-b09, mixed mode)

Code:

public static void main(String[] args) {
  // Set up browser
  ChromeDriver driver = new ChromeDriver();
  driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
  driver.get("https://www.example.com");
  driver.manage().window().maximize();
}

        

Error:

org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection to http://localhost:44211/devtools/browser/34525f00-d1ba-4249-9fc0-904e3b8be194
Build info: version: '4.8.1', revision: '8ebccac989'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-67-generic', java.version: '17.0.5'
Driver info: driver.version: ChromeDriver
    at org.openqa.selenium.remote.http.netty.NettyWebSocket.<init>(NettyWebSocket.java:102)
    at org.openqa.selenium.remote.http.netty.NettyWebSocket.lambda$create$3(NettyWebSocket.java:128)
    at org.openqa.selenium.remote.http.netty.NettyClient.openSocket(NettyClient.java:107)
    at org.openqa.selenium.devtools.Connection.<init>(Connection.java:78)
    at org.openqa.selenium.chromium.ChromiumDriver.lambda$new$2(ChromiumDriver.java:116)
    at java.base/java.util.Optional.map(Optional.java:260)
    at org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:114)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:82)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:50)
    at TTR.TicketReportWeekly.main(TicketReportWeekly.java:33)

Can anyone help me understand this error and also resolve it?

3 Answers 3

1

Here are a few things that would normally be needed to check to resolve the issue:

  1. Update ChromeDriver: Make sure you have the latest version of ChromeDriver that is compatible with your version of Chrome. You can check the version compatibility matrix on the ChromeDriver website to ensure that you have the correct version.

  2. Check Chrome version: Verify that the version of Google Chrome installed on your system matches the version of ChromeDriver you are using. If they are not compatible, you may need to either update Chrome or use an older version of ChromeDriver.

  3. Check Selenium version: Ensure that you have the latest version of Selenium installed on your system, which is compatible with your version of ChromeDriver and Chrome.

  4. Disable Chrome sandbox: Try disabling the Chrome sandbox to see if that resolves the issue. This can be done by passing the --no-sandbox argument to the ChromeDriver.

  5. Check port conflicts: Verify that there are no port conflicts on the system that might be preventing the ChromeDriver from connecting to Chrome. You can check for any conflicting processes using the following command on Linux:

sudo netstat -lnp | grep 44211

This will display a list of processes running on port 44211. If any process is using this port, you can kill it using the kill command and try running the test again.

If none of the above help resolve the issue, you can do this:

public static void main(String[] args) {
  // Set up browser
  ChromeOptions ops = new ChromeOptions();
  ops.addArguments("--remote-allow-origins=*");
  ChromeDriver driver = new ChromeDriver(ops);
  driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
  driver.get("https://www.example.com");
  driver.manage().window().maximize();
}

This solved the issue for me.

1
  • ops.addArguments("--remote-allow-origins=*") this did resolve the issue for me. Had all software and tools to the latest version. Mar 11 at 2:16
1
ChromeOptions ops = new ChromeOptions();
ops.addArguments("--remote-allow-origins=*");
ChromeDriver driver = new ChromeDriver(ops);

This Script sorted my issue. Thanks a lot!

2
  • Welcome to the community. First, it's not so great to start off with "Great Bro." This can come across as arrogant and sexist, as there are a lot of women in this group. So, I'd recommend removing that. Second, can you expand on your answer and explain why this is a good solution? Explaining why helps others learn.
    – Lee Jensen
    Mar 14 at 15:37
  • Balasubramani, now you should have enough points to comment. So please move this to the comment. Lee Jensen, once this is moved to the comment on the right answer, I wouldn't be offended with the Bro. I do understand the concern of it in an answer. Mar 15 at 2:17
0

Download the chrome-driver from the selenium.dev as per your chrome version. When the chromedriver and chrome browser version doesn't match script won't run.

1
  • Thanks. I already did that. The version of Selenium standalone server mentioned in the question description was downloaded today from the official Selenium website. Mar 10 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.