public class Network
extends java.lang.Object
Constructor and Description |
---|
Network() |
Modifier and Type | Method and Description |
---|---|
static Command<java.lang.Void> |
clearBrowserCache() |
static Command<java.lang.Void> |
clearBrowserCookies() |
static Command<java.lang.Void> |
continueInterceptedRequest(InterceptionId interceptionId,
java.util.Optional<ErrorReason> errorReason,
java.util.Optional<java.lang.String> rawResponse,
java.util.Optional<java.lang.String> url,
java.util.Optional<java.lang.String> method,
java.util.Optional<java.lang.String> postData,
java.util.Optional<java.util.Map<java.lang.String,java.lang.String>> headers,
java.util.Optional<AuthChallengeResponse> authChallengeResponse)
Response to Network.requestIntercepted which either modifies the request to continue with any modifications, or blocks it, or completes it with the provided response bytes.
|
static Event<DataReceived> |
dataReceived()
Fired when data chunk was received over the network.
|
static Command<java.lang.Void> |
deleteCookies(java.lang.String name,
java.util.Optional<java.lang.String> url,
java.util.Optional<java.lang.String> domain,
java.util.Optional<java.lang.String> path)
Deletes browser cookies with matching name and url or domain/path pair
|
static Command<java.lang.Void> |
disable()
Disables network tracking, prevents network events from being sent to the client.
|
static Command<java.lang.Void> |
emulateNetworkConditions(boolean offline,
double latency,
double downloadThroughput,
double uploadThroughput,
java.util.Optional<ConnectionType> connectionType)
Activates emulation of network conditions.
|
static Command<java.lang.Void> |
enable(java.util.Optional<java.lang.Integer> maxTotalBufferSize,
java.util.Optional<java.lang.Integer> maxResourceBufferSize,
java.util.Optional<java.lang.Integer> maxPostDataSize)
Enables network tracking, network events will now be delivered to the client.
|
static Event<EventSourceMessageReceived> |
eventSourceMessageReceived()
Fired when EventSource message is received
|
static Command<Cookies> |
getAllCookies()
Returns all browser cookies.
|
static Command<java.util.List<java.lang.String>> |
getCertificate(java.lang.String origin)
Returns the DER-encoded certificate (EXPERIMENTAL)
|
static Command<Cookies> |
getCookies(java.util.Optional<java.util.List<java.lang.String>> urls)
Returns all browser cookies for the current URL.
|
static Command<java.lang.String> |
getRequestPostData(RequestId requestId)
Returns post data sent with the request.
|
static Command<ResponseBody> |
getResponseBody(RequestId requestId)
Returns content served for the given request
|
static Command<ResponseBody> |
getResponseBodyForInterception(InterceptionId interceptionId)
Returns content served for the given currently intercepted request (EXPERIMENTAL)
|
static Event<LoadingFailed> |
loadingFailed()
Fired when HTTP request has failed to load
|
static Event<LoadingFinished> |
loadingFinished()
Fired when HTTP request has finished loading
|
static Command<java.lang.Void> |
replayXHR(RequestId requestId) |
static Event<RequestIntercepted> |
requestIntercepted()
Details of an intercepted HTTP request, which must be either allowed, blocked, modified or mocked.(EXPERIMENTAL)
|
static Event<RequestId> |
requestServedFromCache()
Fired if request ended up loading from cache
|
static Event<RequestWillBeSent> |
requestWillBeSent()
Fired when page is about to send HTTP request
|
static Event<ResourceChangedPriority> |
resourceChangedPriority()
Fired when resource loading priority is changed (EXPERIMENTAL)
|
static Event<ResponseReceived> |
responseReceived()
Fired when HTTP response is available.
|
static Command<java.util.List<SearchMatch>> |
searchInResponseBody(RequestId requestId,
java.lang.String query,
java.util.Optional<java.lang.Boolean> caseSensitive,
java.util.Optional<java.lang.Boolean> isRegex)
Searches for given string in response content (EXPERIMENTAL)
|
static Command<java.lang.Void> |
setBlockedURLs(java.util.List<java.lang.String> urls)
Blocks URLs from loading (EXPERIMENTAL)
|
static Command<java.lang.Void> |
setBypassServiceWorker(boolean bypass)
Toggles ignoring of service worker for each request.
|
static Command<java.lang.Void> |
setCacheDisabled(boolean cacheDisabled)
Toggles ignoring cache for each request.
|
static Command<java.lang.Boolean> |
setCookie(org.openqa.selenium.Cookie cookie,
java.util.Optional<java.lang.String> url)
Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist
|
static Command<java.lang.Void> |
setDataSizeLimitsForTest(int maxTotalSize,
int maxResourceSize)
(EXPERIMENTAL)
|
static Command<java.lang.Void> |
setExtraHTTPHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
Specifies whether to always send extra HTTP headers with the requests from this page.
|
static Command<java.lang.Void> |
setRequestInterception(java.util.List<RequestPattern> patterns)
Sets the requests to intercept that match the provided patterns and optionally resource types (EXPERIMENTAL)
|
static Command<java.lang.Void> |
setUserAgentOverride(java.lang.String userAgent,
java.util.Optional<java.lang.String> acceptLanguage,
java.util.Optional<java.lang.String> platform)
Allows overriding user agent with the given string
|
static Event<SignedExchangeReceived> |
signedExchangeReceived()
Fired when a signed exchange was received over the network (EXPERIMENTAL)
|
static Command<java.lang.String> |
takeResponseBodyForInterceptionAsStream(InterceptionId interceptionId)
Returns a handle to the stream representing the response body.
|
static Event<WebSocketClosed> |
webSocketClosed()
Fired upon WebSocket creation.
|
static Event<WebSocketCreated> |
webSocketCreated()
Fired upon WebSocket creation.
|
static Event<WebSocketFrameError> |
webSocketFrameError()
Fired when WebSocket message error occurs.
|
static Event<WebSocketFrame> |
webSocketFrameReceived()
Fired when WebSocket message is received.
|
static Event<WebSocketFrame> |
webSocketFrameSent()
Fired when WebSocket message is sent.
|
public static Command<java.lang.Void> clearBrowserCache()
public static Command<java.lang.Void> clearBrowserCookies()
@Beta public static Command<java.lang.Void> continueInterceptedRequest(InterceptionId interceptionId, java.util.Optional<ErrorReason> errorReason, java.util.Optional<java.lang.String> rawResponse, java.util.Optional<java.lang.String> url, java.util.Optional<java.lang.String> method, java.util.Optional<java.lang.String> postData, java.util.Optional<java.util.Map<java.lang.String,java.lang.String>> headers, java.util.Optional<AuthChallengeResponse> authChallengeResponse)
interceptionId
- Identifier for the intercepted requesterrorReason
- If set this causes the request to fail with the given reason.
Passing Aborted for requests marked with isNavigationRequest also cancels the navigation. Must not be set in response to an authChallengerawResponse
- If set the requests completes using with the provided base64 encoded raw response, including HTTP status line and headers etc...
Must not be set in response to an authChallengeurl
- If set the request url will be modified in a way that's not observable by page. Must not be set in response to an authChallengemethod
- If set this allows the request method to be overridden. Must not be set in response to an authChallengepostData
- If set this allows postData to be set. Must not be set in response to an authChallengeheaders
- If set this allows the request headers to be changed. Must not be set in response to an authChallengeauthChallengeResponse
- Response to a requestIntercepted with an authChallenge. Must not be set otherwisepublic static Command<java.lang.Void> deleteCookies(java.lang.String name, java.util.Optional<java.lang.String> url, java.util.Optional<java.lang.String> domain, java.util.Optional<java.lang.String> path)
name
- Name of the cookies to removeurl
- If specified, deletes all the cookies with the given name where domain and path match provided URLdomain
- If specified, deletes only cookies with the exact domain.path
- If specified, deletes only cookies with the exact pathpublic static Command<java.lang.Void> disable()
public static Command<java.lang.Void> emulateNetworkConditions(boolean offline, double latency, double downloadThroughput, double uploadThroughput, java.util.Optional<ConnectionType> connectionType)
offline
- True to emulate internet disconnection.latency
- Minimum latency from request sent to response headers received (ms).downloadThroughput
- Maximal aggregated download throughput (bytes/sec). -1 disables download throttling.uploadThroughput
- Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling.connectionType
- The underlying connection technology that the browser is supposedly using.public static Command<java.lang.Void> enable(java.util.Optional<java.lang.Integer> maxTotalBufferSize, java.util.Optional<java.lang.Integer> maxResourceBufferSize, java.util.Optional<java.lang.Integer> maxPostDataSize)
maxTotalBufferSize
- Buffer size in bytes to use when preserving network payloads (XHRs, etc).maxResourceBufferSize
- Per-resource buffer size in bytes to use when preserving network payloads (XHRs, etc).maxPostDataSize
- Longest post body size (in bytes) that would be included in requestWillBeSent notificationpublic static Command<Cookies> getAllCookies()
@Beta public static Command<java.util.List<java.lang.String>> getCertificate(java.lang.String origin)
origin
- Origin to get certificate forpublic static Command<Cookies> getCookies(java.util.Optional<java.util.List<java.lang.String>> urls)
urls
- The list of URLs for which applicable cookies will be fetchedpublic static Command<ResponseBody> getResponseBody(RequestId requestId)
requestId
- Identifier of the network request to get content forpublic static Command<java.lang.String> getRequestPostData(RequestId requestId)
requestId
- Identifier of the network request to get content for.@Beta public static Command<ResponseBody> getResponseBodyForInterception(InterceptionId interceptionId)
interceptionId
- Identifier for the intercepted request to get body for@Beta public static Command<java.lang.String> takeResponseBodyForInterceptionAsStream(InterceptionId interceptionId)
interceptionId
- Identifier for the intercepted request to get body forpublic static Command<java.lang.Void> replayXHR(RequestId requestId)
requestId
- Identifier of XHR to replay@Beta public static Command<java.util.List<SearchMatch>> searchInResponseBody(RequestId requestId, java.lang.String query, java.util.Optional<java.lang.Boolean> caseSensitive, java.util.Optional<java.lang.Boolean> isRegex)
requestId
- Identifier of the network response to searchquery
- String to search for.caseSensitive
- If true, search is case sensitiveisRegex
- If true, treats string parameter as regex@Beta public static Command<java.lang.Void> setBlockedURLs(java.util.List<java.lang.String> urls)
urls
- URL patterns to block. Wildcards ('*') are allowed.@Beta public static Command<java.lang.Void> setBypassServiceWorker(boolean bypass)
bypass
- Bypass service worker and load from networkpublic static Command<java.lang.Void> setCacheDisabled(boolean cacheDisabled)
cacheDisabled
- Cache disabled state.public static Command<java.lang.Boolean> setCookie(org.openqa.selenium.Cookie cookie, java.util.Optional<java.lang.String> url)
cookie
- Cookie object where Name and Value are mandatoryurl
- The request-URI to associate with the setting of the cookie. This value can affect the default domain and path values of the created cookie@Beta public static Command<java.lang.Void> setDataSizeLimitsForTest(int maxTotalSize, int maxResourceSize)
maxTotalSize
- Maximum total buffer sizemaxResourceSize
- Maximum per-resource sizepublic static Command<java.lang.Void> setExtraHTTPHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
headers
- Map with extra HTTP headers.@Beta public static Command<java.lang.Void> setRequestInterception(java.util.List<RequestPattern> patterns)
patterns
- Requests matching any of these patterns will be forwarded and wait for the corresponding continueInterceptedRequest call.public static Command<java.lang.Void> setUserAgentOverride(java.lang.String userAgent, java.util.Optional<java.lang.String> acceptLanguage, java.util.Optional<java.lang.String> platform)
userAgent
- User agent to useacceptLanguage
- Browser langugage to emulateplatform
- The platform navigator.platform should returnpublic static Event<DataReceived> dataReceived()
public static Event<EventSourceMessageReceived> eventSourceMessageReceived()
public static Event<LoadingFailed> loadingFailed()
public static Event<LoadingFinished> loadingFinished()
public static Event<RequestId> requestServedFromCache()
@Beta public static Event<ResourceChangedPriority> resourceChangedPriority()
@Beta public static Event<SignedExchangeReceived> signedExchangeReceived()
public static Event<RequestWillBeSent> requestWillBeSent()
@Beta public static Event<RequestIntercepted> requestIntercepted()
RequestIntercepted
Objectpublic static Event<ResponseReceived> responseReceived()
ResponseReceived
Objectpublic static Event<WebSocketFrameError> webSocketFrameError()
public static Event<WebSocketCreated> webSocketCreated()
public static Event<WebSocketClosed> webSocketClosed()
public static Event<WebSocketFrame> webSocketFrameReceived()
public static Event<WebSocketFrame> webSocketFrameSent()