-
-
Save akashdktyagi/a446c90666c4f458e7cb01e53446d2fc to your computer and use it in GitHub Desktop.
Use of Selenium Dev Tools CDP to modify header of the request- add authorization token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
URL gridUrl = new URL("url"); | |
EdgeOptions edgeOptions = new EdgeOptions(); | |
edgeOptions.setPlatformName(String.valueOf(Platform.LINUX)); | |
edgeOptions.addArguments("no-sandbox"); | |
// EdgeDriver driver = new EdgeDriver(edgeOptions); | |
EdgeDriver driver = new EdgeDriver(); | |
// RemoteWebDriver driver = new RemoteWebDriver(gridUrl); | |
DevTools devTools = driver.getDevTools(); | |
devTools.createSession(); | |
devTools.send(Network.enable(Optional.empty(),Optional.empty(),Optional.empty())); | |
Map<String, Object> headersMap = new HashMap<>(); | |
headersMap.put("Authorization","akash"); | |
Headers header = new Headers(headersMap); | |
devTools.send(Network.setExtraHTTPHeaders(header)); | |
// driver.executeCdpCommand("Emulation.setDeviceMetricsOverride",deviceMetrics); | |
driver.get("temp"); | |
driver.quit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello!
In this case You add an extra HTTP header.
Is it possible to change the value of an existing HTTP header?
I try it with devtools I added the same attribute twice in a row with a different value, but it didn't change.
And I try it with BrowserMobProxy, but it doesen't work for me also.
Thanks, br, Peter