I tried to invoke the website using Selenium and Chrome browser v111.
The browser is opening but the website is not invoking. It is working properly but after updating chrome "Version 111.0.5563.65 (Official Build) (64-bit)" I'm getting this problem:
org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection
I tried, Eclipse IDE for Enterprise Java Developers (includes Incubating components) Version: 2020-12 (4.18.0) Build id: 20201210-1552.
This is the code:
package com.testng.library_Files;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.testng.annotations.Test;
public class one {
WebDriver driver=null;
@Test(priority = 1)
public void DoSetup()
{
//System.setProperty("webdriver.chrome.driver","./src/main/java/drivers/chromedriver.exe");
ChromeOptions options= new ChromeOptions();
options.setHeadless(true);
//driver= new ChromeDriver(options);
driver= new ChromeDriver();
}
@Test(priority = 2)
public void LaunchURL()
{
driver.get("https://www.google.com");
}
}
Please help me to solve this issue.
I followed the below answer: https://stackoverflow.com/a/75703971/21386874
options.addArguments("--remote-allow-origins=*");
I tried but it is not working.
In my project, I got the below error.
Error:
org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection to http://localhost:49877/devtools/browser/3a3af47d-732a-4337-a91c-18c8ced545cd Build info: version: '4.5.3', revision: '4b786a1e430'
Ans:
I downloaded the newest chromedriver.exe with the 111.0.5563.64 version. Also, I added one more dependency:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-http-jdk-client</artifactId>
<version>4.5.0</version>
</dependency>
And added this code line at the first line into the @BeforeTest
method:
System.setProperty("webdriver.http.factory", "jdk-http-client");