SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
29.74k stars 8.02k forks source link

[🚀 Feature]: [java] BiDi Add an ability to add headers in BeforeRequestSent #14137

Closed kasprzakdanielt closed 2 weeks ago

kasprzakdanielt commented 2 weeks ago

Feature and motivation

Since we have the ability to intercept requests before they are sent. Would be useful to add/remove headers.

Usage example

Inside onBeforeRequestSent I would like to be able to modify request headers.

          try (Network network = new Network(driver)) {
            CompletableFuture<BeforeRequestSent> future = new CompletableFuture<>();
            network.onBeforeRequestSent(future::complete);
            driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html");

            BeforeRequestSent requestSent = future.get(5, TimeUnit.SECONDS);
        }
github-actions[bot] commented 2 weeks ago

@kasprzakdanielt, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

pujagani commented 2 weeks ago

Hey! You can already do this in Java. Refer https://github.com/SeleniumHQ/selenium/blob/trunk/java/test/org/openqa/selenium/bidi/network/NetworkCommandsTest.java#L81 The continue request parameters has more parameters that you can set. Ensure it is supported by the browser under test though, since the BiDi is work in progress. Refer https://wpt.fyi/results/webdriver/tests/bidi/network/continue_request?label=experimental&label=master&aligned.