Created
July 3, 2019 13:24
-
-
Save adiohana/0d7d174c63596cfd0b09f1e192b5b635 to your computer and use it in GitHub Desktop.
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
@Test | |
public void interceptRequestAndContinue() { | |
//enable Network | |
chromeDevTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty())); | |
//add listener to intercept request and continue | |
chromeDevTools.addListener(Network.requestIntercepted(), | |
requestIntercepted -> chromeDevTools.send( | |
Network.continueInterceptedRequest(requestIntercepted.getInterceptionId(), | |
Optional.empty(), | |
Optional.empty(), | |
Optional.empty(), Optional.empty(), | |
Optional.empty(), | |
Optional.empty(), Optional.empty()))); | |
//set request interception only for css requests | |
RequestPattern requestPattern = new RequestPattern("*.css", ResourceType.Stylesheet, InterceptionStage.HeadersReceived); | |
chromeDevTools.send(Network.setRequestInterception(ImmutableList.of(requestPattern))); | |
chromeDriver.get("https://apache.org"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment