Last active
July 3, 2019 12:58
-
-
Save adiohana/d43895d3b9fb2173905e72ea7615f8fe 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 filterUrls() { | |
//enable Network | |
chromeDevTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty())); | |
//set blocked URL patterns | |
chromeDevTools.send(Network.setBlockedURLs(ImmutableList.of("*.css", "*.png"))); | |
//add event listener to verify that css and png are blocked | |
chromeDevTools.addListener(Network.loadingFailed(), loadingFailed -> { | |
if (loadingFailed.getResourceType().equals(ResourceType.Stylesheet)) { | |
Assert.assertEquals(loadingFailed.getBlockedReason(), BlockedReason.inspector); | |
} | |
else if (loadingFailed.getResourceType().equals(ResourceType.Image)) { | |
Assert.assertEquals(loadingFailed.getBlockedReason(), BlockedReason.inspector); | |
} | |
}); | |
chromeDriver.get("https://apache.org"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment