I'm trying to use selenium dev tools java API, and for multiple API methods I'm getting java.util.concurrent.TimeoutException
.
For example I'm trying to use Network.clearBrowserCache
, which should work accroding to chromedriver docs: https://chromedevtools.github.io/devtools-protocol/tot/Network/
I'm calling clearBrowserCache
using following code:
chromeDriver.getDevTools().send(Network.clearBrowserCache())
It fails, but at the same time if I use other devTools commands like this:
chromeDriver.getDevTools().send(Browser.getVersion())
It returns data properly.
Try calling createSession
before calling clearBrowserCache
.
Using your setup, this works:
chromeDriver.getDevTools().createSession();
chromeDriver.getDevTools().send(Network.clearBrowserCache())
and this produces java.util.concurrent.TimeoutException
:
chromeDriver.getDevTools().send(Network.clearBrowserCache())
You can verify that the browser cache has been cleared with this snippet:
ChromeDriver driver = new ChromeDriver();
driver.get("https://refreshyourcache.com/en/cache-test/");
Thread.sleep(2000);
driver.getDevTools().createSession();
driver.getDevTools().send(Network.clearBrowserCache());
driver.get("https://refreshyourcache.com/en/cache-test/");
Thread.sleep(5000);
If you run the code, the pages displayed in the test browser will show these images:
If you commment out the line driver.getDevTools().send(Network.clearBrowserCache());
then you get a different result:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With