Selenium CDP Connection error on Fetch : Chrome DevTools

111 views Asked by At

Getting errors in Fetch continue request implementation

Chrome version : 18.0.5993 Java : 17

https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-continueRequest

Errors

org.openqa.selenium.devtools.DevToolsException: {"id":2440,"error":{"code":-32000,"message":"Invalid state for continueInterceptedRequest"},"sessionId":"CD483E6DB97D096120A659EDA82D6A29"} org.openqa.selenium.devtools.DevToolsException: {"id":2441,"error":{"code":-32000,"message":"Invalid state for continueInterceptedRequest"},"sessionId":"CD483E6DB97D096120A659EDA82D6A29"}

Code

Optional devToolsOpt = ((HasDevTools)driver).maybeGetDevTools();

    if (devToolsOpt.isPresent()) {
        DevTools devTools = devToolsOpt.get();
        devTools.createSessionIfThereIsNotOne();
        devTools.send(Fetch.enable(Optional.empty(), Optional.empty()));
        devTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty()));
        devTools.addListener(Fetch.requestPaused(), req -> {
        List<HeaderEntry> customHeaders = new ArrayList<>();

        // adding current request headers + additional headers to customHeaders

  
         devTools.send(Fetch.continueRequest(req.getRequestId(), Optional.empty(), Optional.empty(),
            Optional.empty(), Optional.of(customHeaders), Optional.empty()));
           
        });
    }
0

There are 0 answers