Class NetworkInterceptor
- java.lang.Object
-
- org.openqa.selenium.support.devtools.NetworkInterceptor
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class NetworkInterceptor extends java.lang.Object implements java.io.Closeable
Provides a mechanism for stubbing out responses to requests in drivers which implementHasDevTools
. Usage is done by specifying aRoute
, which will be checked for every request to see if that request should be handled or not. Note that the URLs given to theRoute
will be fully qualified.Example usage:
Route route = Route.matching(req -> GET == req.getMethod() && req.getUri().endsWith("/example")) .to(() -> req -> new HttpResponse().setContent(Contents.utf8String("Hello, World!"))); try (NetworkInterceptor interceptor = new NetworkInterceptor(driver, route)) { // Your code here. }
-
-
Field Summary
Fields Modifier and Type Field Description static org.openqa.selenium.remote.http.HttpResponse
PROCEED_WITH_REQUEST
-
Constructor Summary
Constructors Constructor Description NetworkInterceptor(org.openqa.selenium.WebDriver driver, org.openqa.selenium.remote.http.Route route)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
-