What happened?
I was trying to test the block url with multiple windows or tab. I am able to block the urls on different tabs and windows, but when I try to call close() on the devtools object it throws "org.openqa.selenium.WebDriverException: {"id":19,"error":{"code":-32602,"message":"No session with given id"}}". First I got the idea that each window/tab has it's own devtool session, but then how do I manage it as createSession*() methods returns void.
How can we reproduce the issue?
package com.seleniumtest.devtools;
import java.util.Optional;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WindowType;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chromium.ChromiumDriver;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.v107.network.Network;
import com.google.common.collect.ImmutableList;
public class DevToolBug {
static DevTools devTools;
static WebDriver driver = null;
public static void main(String[] args) {
try {
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
driver.manage().window().maximize();
devTools = ((ChromiumDriver) driver).getDevTools();
devTools.createSession();
devTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty()));
devTools.send(Network.setBlockedURLs(ImmutableList.of("*.css")));
driver.get("https://amazon.com");
driver.switchTo().newWindow(WindowType.TAB);
devTools.createSession(driver.getWindowHandle());
devTools.send(org.openqa.selenium.devtools.v105.network.Network.enable(Optional.empty(), Optional.empty(), Optional.empty()));
devTools.send(Network.setBlockedURLs(ImmutableList.of("*.css")));
driver.get("https://amazon.com");
driver.switchTo().newWindow(WindowType.WINDOW);
devTools.createSession(driver.getWindowHandle());
devTools.send(org.openqa.selenium.devtools.v105.network.Network.enable(Optional.empty(), Optional.empty(), Optional.empty()));
devTools.send(Network.setBlockedURLs(ImmutableList.of("*.css")));
driver.get("https://amazon.com");
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if (devTools != null) {
devTools.close(); // <-- Issue.
}
if (driver != null) {
driver.quit();
}
}
}
}
Relevant log output
Task :DevToolBug.main()
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 108.0.5359.71 (1e0e3868ee06e91ad636a874420e3ca3ae3756ac-refs/branch-heads/5359@{#1016}) on port 48713
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Dec 16, 2022 1:58:25 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 108, so returning the closest version found: 107
Exception in thread "main" org.openqa.selenium.devtools.DevToolsException: {"id":19,"error":{"code":-32602,"message":"No session with given id"}}
Build info: version: '4.6.0', revision: '79f1c02ae20'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.1'
Driver info: driver.version: unknown
at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:159)
at org.openqa.selenium.devtools.DevTools.disconnectSession(DevTools.java:67)
at org.openqa.selenium.devtools.DevTools.close(DevTools.java:60)
at com.seleniumtest.devtools.DevToolBug.main(DevToolBug.java:50)
Caused by: org.openqa.selenium.WebDriverException: {"id":19,"error":{"code":-32602,"message":"No session with given id"}}
Build info: version: '4.6.0', revision: '79f1c02ae20'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.1'
Driver info: driver.version: unknown
at org.openqa.selenium.devtools.Connection.handle(Connection.java:234)
at org.openqa.selenium.devtools.Connection.access$200(Connection.java:58)
at org.openqa.selenium.devtools.Connection$Listener.lambda$onText$0(Connection.java:199)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Operating System
Windows 10
Selenium version
4.6.0
What are the browser(s) and version(s) where you see this issue?
108.0.5359.125
What are the browser driver(s) and version(s) where you see this issue?
Chrome Driver 107
Are you using Selenium Grid?
NA
What happened?
I was trying to test the block url with multiple windows or tab. I am able to block the urls on different tabs and windows, but when I try to call close() on the devtools object it throws "org.openqa.selenium.WebDriverException: {"id":19,"error":{"code":-32602,"message":"No session with given id"}}". First I got the idea that each window/tab has it's own devtool session, but then how do I manage it as createSession*() methods returns void.
How can we reproduce the issue?
Relevant log output
Operating System
Windows 10
Selenium version
4.6.0
What are the browser(s) and version(s) where you see this issue?
108.0.5359.125
What are the browser driver(s) and version(s) where you see this issue?
Chrome Driver 107
Are you using Selenium Grid?
NA