Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: org.openqa.selenium.WebDriverException: java.io.IOException: Output closed seen on calling devTools.createSession() #1555

Closed
jonn-set opened this issue Jan 5, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@jonn-set
Copy link

jonn-set commented Jan 5, 2024

What happened?

I am upgrading from selenium 4.13 to 4.16.1 to stay in line with the browser version on my machine (I have no control over the version as its controlled by our organisation).

I am using BiDI/CDP Network Interception and it works alright in 4.13 but does not work in 4.16.1 and ends up giving the above error when devTools.createSession() or .createSessionIfThereIsNotOne() is called. I am using Cucumber-Java8 as my Test Runner.

My source code below:

protected DevTools interceptResponseEndingWith(String urlPrefix) {
    log.info("Starting HTTP Response interception...");
    DevTools devTools = ((HasDevTools) driver).getDevTools();
    devTools.createSessionIfThereIsNotOne();
    devTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty()));
    final RequestId[] requestId = new RequestId[1];
    devTools.addListener(
        Network.responseReceived(),
        responseConsumer -> {
          Response response = responseConsumer.getResponse();
          log.info("Intercepted Response--> {}", response.getUrl());
          requestId[0] = responseConsumer.getRequestId();
          if (response.getUrl().endsWith(urlPrefix)
              && !response.getUrl().contains("www.google-analytics.com")) {
            log.info("Filtered Response--> {}", response.getUrl());
            log.info("Filtered ResponseId --> {}", requestId[0]);
            log.info("Response Status Code --> {}", response.getStatus());
            scenarioContext.responseStatusCode = response.getStatus();
            scenarioContext.responseBody =
                devTools.send(Network.getResponseBody(requestId[0])).getBody();
            log.info("Response Body--> {}", scenarioContext.responseBody);
          }
        });
    log.info("Started HTTP Response interception!!");
    return devTools;
  }

Stacktrace:

org.openqa.selenium.WebDriverException: java.io.IOException: Output closed
Build info: version: '4.16.1', revision: '9b4c83354e'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.0.1'
Driver info: driver.version: unknown
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:304)
	at org.openqa.selenium.remote.http.WebSocket.sendText(WebSocket.java:32)
	at org.openqa.selenium.devtools.Connection.send(Connection.java:172)
	at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:183)
	at org.openqa.selenium.devtools.DevTools.findTarget(DevTools.java:171)
	at org.openqa.selenium.devtools.DevTools.createSession(DevTools.java:131)
	at org.openqa.selenium.devtools.DevTools.createSession(DevTools.java:117)
	at com.jcs.race.steps.BaseSteps.interceptResponseEndingWith(BaseSteps.java:104)
...
Caused by: java.io.IOException: Output closed
	at java.net.http/jdk.internal.net.http.websocket.MessageEncoder.encodeText(MessageEncoder.java:136)
	at java.net.http/jdk.internal.net.http.websocket.TransportImpl$SendTask$1.onText(TransportImpl.java:366)
	at java.net.http/jdk.internal.net.http.websocket.TransportImpl$SendTask$1.onText(TransportImpl.java:357)
	at java.net.http/jdk.internal.net.http.websocket.MessageQueue.peek(MessageQueue.java:223)
	at java.net.http/jdk.internal.net.http.websocket.TransportImpl$SendTask.run(TransportImpl.java:545)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
	at java.net.http/jdk.internal.net.http.websocket.TransportImpl.sendText(TransportImpl.java:149)
	at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.sendText(WebSocketImpl.java:184)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.lambda$send$1(JdkHttpClient.java:271)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:294)
	at org.openqa.selenium.remote.http.WebSocket.sendText(WebSocket.java:32)
	at org.openqa.selenium.devtools.Connection.send(Connection.java:172)
	at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:183)
	at org.openqa.selenium.devtools.DevTools.findTarget(DevTools.java:171)
	at org.openqa.selenium.devtools.DevTools.createSession(DevTools.java:131)
	at org.openqa.selenium.devtools.DevTools.createSession(DevTools.java:117)
	at com.jcs.race.steps.BaseSteps.interceptResponseEndingWith(BaseSteps.java:104)

What browsers and operating systems are you seeing the problem on?

Browser: Edge v120
OS: Windows 10

I haven't been able to check this on other browsers as they dont seem work with our Website under test, different issues with Chrome and Firefox.

@jonn-set jonn-set added bug Something isn't working needs-triaging labels Jan 5, 2024
Copy link
Contributor

github-actions bot commented Jan 5, 2024

@jonn-set, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@diemol
Copy link
Member

diemol commented Jan 5, 2024

This is the repository for the documentation, for Selenium issues, please use https://github.com/SeleniumHQ/selenium.

Also, note that Java 8 is not supported anymore.

@diemol diemol closed this as not planned Won't fix, can't repro, duplicate, stale Jan 5, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jan 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants