question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[🐛 Bug]: TimeoutException with DevTools protocol after starting a new WebDriver.

See original GitHub issue

What happened?

When a new WebDriver is started (devToolEventSecond method), an exception is thrown.

How can we reproduce the issue?

Utils:
public final class Util {

    public static WebDriver driver = new Augmenter().augment(getWebDriver());
    public static DevTools devTools = ((HasDevTools) driver).getDevTools();

}

Test:
public class DraftTest {

    @BeforeMethod
    public void init() {
        open("https://www.google.com/");
    }

    @Test
    public void devToolEvent() {
        Util.devTools.createSession();
        Util.devTools.send(Network.clearBrowserCache());
    }

    @Test
    public void devToolEventSecond() {
        Util.devTools.createSession();
        Util.devTools.send(Network.clearBrowserCache());
    }

    @AfterMethod
    public void tearDown() {
        closeWebDriver();
    }

POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>Draft</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.codeborne</groupId>
            <artifactId>selenide-testng</artifactId>
            <version>6.3.1</version>
        </dependency>
        <dependency>
            <groupId>net.bytebuddy</groupId>
            <artifactId>byte-buddy</artifactId>
            <version>1.12.7</version>
        </dependency>
    </dependencies>
</project>

Relevant log output

org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.1.2', revision: '9a5a329c5a'
System info: host: 'My-MacBook-Air.local', ip: 'IP', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '12.1', java.version: '16.0.2'
Driver info: driver.version: unknown

	at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:161)
	at org.openqa.selenium.devtools.DevTools.createSession(DevTools.java:95)
	at DraftTest.devToolEventSecond(DraftTest.java:29)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
	at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:598)
	at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
	at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
	at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:824)
	at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.testng.TestRunner.privateRun(TestRunner.java:794)
	at org.testng.TestRunner.run(TestRunner.java:596)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:377)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:371)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)
	at org.testng.SuiteRunner.run(SuiteRunner.java:276)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1134)
	at org.testng.TestNG.runSuites(TestNG.java:1063)
	at org.testng.TestNG.run(TestNG.java:1031)
	at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
	at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)
Caused by: java.util.concurrent.TimeoutException
	at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1956)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2091)
	at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:150)
	... 29 more

Operating System

macOS Monterey

Selenium version

Java 4.1.2

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

Chrome 98

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

ChromeDriver 98.0.4758.80

Are you using Selenium Grid?

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
arsen-papoyancommented, Feb 10, 2022

Did you mean like this?

public class DraftTest {

    WebDriver driver;
    DevTools devTools;

    @BeforeMethod
    public void init() {
        open("https://www.google.com/");
        driver = new Augmenter().augment(getWebDriver());
        devTools = ((HasDevTools) driver).getDevTools();
    }

    @Test
    public void devToolEvent() {
        devTools.createSession();
        devTools.send(Network.clearBrowserCache());
    }

    @Test
    public void devToolEventSecond() {
        devTools.createSession();
        devTools.send(Network.clearBrowserCache());
    }

    @AfterMethod
    public void tearDown() {
        closeWebDriver();
    }

Yes, it works.

0reactions
github-actions[bot]commented, Mar 13, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Timeout exception when using dev tools with selenium-java ...
Try calling createSession before calling clearBrowserCache . Using your setup, this works: chromeDriver.getDevTools().
Read more >
Timed out receiving message from renderer error - chromedriver
I fixed this bug by adding timeout after WebDriver creating. For me it's 1 second timeout. WebDriver dr = new ChromeDriver(options); TimeUnit.
Read more >
Timeout Exception When Using Dev Tools With Seleniumjava ...
When trying to run Selenium tests in Azure DevOps release pipelines we are encountering the following error: OpenQA.Selenium.WebDriverException: The HTTP.
Read more >
WebDriver - W3C
WebDriver is a remote control interface that enables introspection and control of user agents. It provides a platform- and language-neutral ...
Read more >
All Classes | php-webdriver API - GitHub Pages
Provides helper methods for checkboxes and radio buttons. ChromeDevToolsDriver. Provide access to Chrome DevTools Protocol (CDP) commands via HTTP endpoint of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found