Where can I get the Selenium devtool network related Java packages?
I'm getting the following errors:
error: package org.openqa.selenium.devtools.network does not exist
import org.openqa.selenium.devtools.network.Network;
error: package org.openqa.selenium.devtools.network.model does not exist
import org.openqa.selenium.devtools.network.model.Headers;
and I was having a hard time fixing it.
From these two urls,
It seems they both comes from:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-devtools</artifactId>
<version>4.0.0-alpha-5</version>
</dependency>
Is it that I have to install this specific and old version? As I got the latest 4.0.0-rc-1 in target/dependency/selenium-devtools-4.0.0-rc-1.jar
, but I'm still getting the above compilation errors.
How to fix them please?
You can import devtools packages as well as Netowrk
like
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.HasDevTools;
import org.openqa.selenium.devtools.v118.browser.Browser;
import org.openqa.selenium.devtools.v118.network.Network;
import org.openqa.selenium.devtools.v118.network.model.Headers;
import org.openqa.selenium.devtools.v118.performance.Performance;
import org.openqa.selenium.devtools.v118.performance.model.Metric;
import org.openqa.selenium.devtools.v118.runtime.Runtime;
with pom.xml
artifact declaration
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.15.0</version>
</dependency>
See https://www.selenium.dev/documentation/webdriver/bidirectional/chrome_devtools/cdp_api/
Its example on Github: https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk//examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L24-L31