-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Description
What happened?
I recently upgraded to 4.26 from 4.23 and have been facing intermittent issue running tests inside a Selenium Standalone chrome docker container v 130
The point where this is happening is when I call new Augmenter().augment(driver). However the same code works fine for a lot of tests before it starts failing. The exact error is jdk.internal.net.http.websocket.CheckFailedException: Unexpected HTTP response status code 400.
I am trying to intercept a HTTP Request (Response as well sometimes), but before I do that I have to augment the driver instance as its a RemoteWebDriver instance and that's when the exception is being thrown. I have not seen this happen when I am running it locally on a Windows 10 machine.
org.openqa.selenium.remote.http.ConnectionFailedException: JdkWebSocket initial request execution error
Build info: version: '4.26.0', revision: '8ccf0219d7'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '4.18.0-553.22.1.el8_10.x86_64', java.version: '11.0.25'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.http.jdk.JdkHttpClient.openSocket(JdkHttpClient.java:249)
at org.openqa.selenium.devtools.Connection.<init>(Connection.java:89)
at org.openqa.selenium.devtools.SeleniumCdpConnection.<init>(SeleniumCdpConnection.java:36)
at org.openqa.selenium.devtools.SeleniumCdpConnection.lambda$create$3(SeleniumCdpConnection.java:103)
at java.base/java.util.Optional.map(Optional.java:265)
at org.openqa.selenium.devtools.SeleniumCdpConnection.create(SeleniumCdpConnection.java:103)
at org.openqa.selenium.devtools.SeleniumCdpConnection.create(SeleniumCdpConnection.java:49)
at org.openqa.selenium.devtools.DevToolsProvider.getImplementation(DevToolsProvider.java:50)
at org.openqa.selenium.devtools.DevToolsProvider.getImplementation(DevToolsProvider.java:29)
at org.openqa.selenium.remote.Augmenter.augment(Augmenter.java:207)
at org.openqa.selenium.remote.Augmenter.augment(Augmenter.java:178)
at com.jcs.race.steps.BaseSteps.interceptResponseEndingWith(BaseSteps.java:207)
at com.jcs.race.steps.SearchSteps.lambda$new$0(SearchSteps.java:32)
at β½.I search for a valid customer(file:///app/bygg/teamcity-agent/Search.feature:5)
Caused by: java.net.http.WebSocketHandshakeException
at java.net.http/jdk.internal.net.http.websocket.OpeningHandshake.resultFrom(OpeningHandshake.java:224)
at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1072)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
at java.base/java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:610)
at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:840)
at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: jdk.internal.net.http.websocket.CheckFailedException: Unexpected HTTP response status code 400
at java.net.http/jdk.internal.net.http.websocket.OpeningHandshake.checkFailed(OpeningHandshake.java:341)
at java.net.http/jdk.internal.net.http.websocket.OpeningHandshake.handleResponse(OpeningHandshake.java:250)
at java.net.http/jdk.internal.net.http.websocket.OpeningHandshake.resultFrom(OpeningHandshake.java:220)
... 10 more
How can we reproduce the issue?
private CommandExecutor getShutterBugExecutor() {
Tracer tracer = OpenTelemetryTracer.getInstance();
ClientConfig config = ClientConfig.defaultConfig().baseUrl("http://localhost:4444");
CommandExecutor executor =
new HttpCommandExecutor(
Collections.emptyMap(),
config,
new TracedHttpClient.Factory(tracer, Factory.createDefault()));
return new TracedCommandExecutor(executor, tracer);
}
@Bean
private WebDriver setupChrome() {
ChromeOptions options = new ChromeOptions();
options.addArguments(List.of(
"--enable-automation",
"--disable-extensions",
"--disable-client-side-phishing-detection",
"--no-default-browser-check",
"--no-first-run",
"--enable-logging=stderr",
"--log-level=0",
"--disable-dev-shm-usage",
"--user-data-dir=/home/seluser/.config/google-chrome/default"
));
ImmutableCapabilities capabilities = new ImmutableCapabilities("browserName", "chrome");
return new RemoteWebDriver(getShutterBugExecutor(), capabilities.merge(options));
}
// The above bean is autowired into tests
// The below is a method in the test which uses this instance of driver:
protected DevTools interceptRequestEndingWith(String urlPrefix) {
driver = new Augmenter().augment(driver); /*<--This is the point of failure*/
DevTools devTools = ((HasDevTools) driver).getDevTools();
devTools.createSessionIfThereIsNotOne();
devTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty()));
devTools.addListener(
Network.requestWillBeSent(),
requestWillBeSent -> {
Request request = requestWillBeSent.getRequest();
if (request.getUrl().endsWith(urlPrefix)
&& !request.getUrl().contains("www.google-analytics.com")) {
scenarioContext.requestBody = request.getPostData().get();
}
});
return devTools;
}
// The same method works for close to 20 mins before it fails.Relevant log output
org.openqa.selenium.remote.http.ConnectionFailedException: JdkWebSocket initial request execution error
Build info: version: '4.26.0', revision: '8ccf0219d7'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '4.18.0-553.22.1.el8_10.x86_64', java.version: '11.0.25'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.http.jdk.JdkHttpClient.openSocket(JdkHttpClient.java:249)
at org.openqa.selenium.devtools.Connection.<init>(Connection.java:89)
at org.openqa.selenium.devtools.SeleniumCdpConnection.<init>(SeleniumCdpConnection.java:36)
at org.openqa.selenium.devtools.SeleniumCdpConnection.lambda$create$3(SeleniumCdpConnection.java:103)
at java.base/java.util.Optional.map(Optional.java:265)
at org.openqa.selenium.devtools.SeleniumCdpConnection.create(SeleniumCdpConnection.java:103)
at org.openqa.selenium.devtools.SeleniumCdpConnection.create(SeleniumCdpConnection.java:49)
at org.openqa.selenium.devtools.DevToolsProvider.getImplementation(DevToolsProvider.java:50)
at org.openqa.selenium.devtools.DevToolsProvider.getImplementation(DevToolsProvider.java:29)
at org.openqa.selenium.remote.Augmenter.augment(Augmenter.java:207)
at org.openqa.selenium.remote.Augmenter.augment(Augmenter.java:178)
at com.jcs.race.steps.BaseSteps.interceptResponseEndingWith(BaseSteps.java:207)
at com.jcs.race.steps.SearchSteps.lambda$new$0(SearchSteps.java:32)
at β½.I search for a valid customer(file:///app/bygg/teamcity-agent/Search.feature:5)
Caused by: java.net.http.WebSocketHandshakeException
at java.net.http/jdk.internal.net.http.websocket.OpeningHandshake.resultFrom(OpeningHandshake.java:224)
at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1072)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
at java.base/java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:610)
at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:840)
at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: jdk.internal.net.http.websocket.CheckFailedException: Unexpected HTTP response status code 400
at java.net.http/jdk.internal.net.http.websocket.OpeningHandshake.checkFailed(OpeningHandshake.java:341)
at java.net.http/jdk.internal.net.http.websocket.OpeningHandshake.handleResponse(OpeningHandshake.java:250)
at java.net.http/jdk.internal.net.http.websocket.OpeningHandshake.resultFrom(OpeningHandshake.java:220)
... 10 moreOperating System
RHEL8
Selenium version
Java 4.26
What are the browser(s) and version(s) where you see this issue?
Chrome 130
What are the browser driver(s) and version(s) where you see this issue?
chromedriver 130
Are you using Selenium Grid?
No response