Skip to content

[🐛 Bug]: Cannot create DevTools session twice #11606

@apetrivs

Description

@apetrivs

What happened?

Since 4.7.1 selenium version DevTools session cannot be created after DevTools session was opened and closed.
TimeoutException is thrown.

Steps to reproduce:

  1. Create DevTools session
  2. Enable Network.
  3. Close session.
  4. Try to create new session with the same driver.

How can we reproduce the issue?

import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.v108.network.Network;

import java.util.Objects;
import java.util.Optional;

public class Main {

    public static void main(String[] args) {
        WebDriverManager.chromedriver().setup();
        ChromeDriver chromeDriver = null;
        try {
            chromeDriver = new ChromeDriver();
            DevTools devTools = chromeDriver.getDevTools();
            devTools.createSession();
            devTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty()));

            devTools.clearListeners();
            devTools.close();

            devTools = chromeDriver.getDevTools();
            devTools.createSession(); // StackTrace starts here!
            devTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty()));

            devTools.clearListeners();
            devTools.close();
        } finally {
            Objects.requireNonNull(chromeDriver).quit();
        }
    }
}

Relevant log output

SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
Starting ChromeDriver 109.0.5414.74 (e7c5703604daa9cc128ccf5a5d3e993513758913-refs/branch-heads/5414@{#1172}) on port 15746
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Feb 01, 2023 11:52:10 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 109, so returning the closest version found: 108
Exception in thread "main" org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.7.1', revision: 'c6795baf1a3'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.2'
Driver info: driver.version: unknown
	at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:162)
	at org.openqa.selenium.devtools.DevTools.findTarget(DevTools.java:146)
	at org.openqa.selenium.devtools.DevTools.createSession(DevTools.java:115)
	at org.openqa.selenium.devtools.DevTools.createSession(DevTools.java:103)
	at Main.main(Main.java:24)
Caused by: java.util.concurrent.TimeoutException
	at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095)
	at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:151)
	... 4 more

Process finished with exit code 1

Operating System

Windows 10

Selenium version

Java 4.7.1

What are the browser(s) and version(s) where you see this issue?

Chrome: 109.0.5414.120 (64-bit)

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 109.0.5414.74

Are you using Selenium Grid?

no

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-devtoolsIncludes everything BiDi or Chrome DevTools relatedC-javaJava BindingsI-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions