Class Network
- java.lang.Object
-
- org.openqa.selenium.devtools.network.Network
-
public class Network extends java.lang.Object
Network domain allows tracking network activities of the page. It exposes information about http, file, data and other requests and responses, their headers, bodies, timing, etc.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Network.GetResponseBodyForInterceptionResponse
static class
Network.GetResponseBodyResponse
-
Constructor Summary
Constructors Constructor Description Network()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Command<java.lang.Boolean>
canClearBrowserCache()
Deprecated.static Command<java.lang.Boolean>
canClearBrowserCookies()
Deprecated.static Command<java.lang.Boolean>
canEmulateNetworkConditions()
Deprecated.static Command<java.lang.Void>
clearBrowserCache()
Clears browser cache.static Command<java.lang.Void>
clearBrowserCookies()
Clears browser cookies.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<Headers> headers, java.util.Optional<AuthChallengeResponse> authChallengeResponse)
Deprecated.static Event<DataReceived>
dataReceived()
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(java.lang.Boolean offline, java.lang.Number latency, java.lang.Number downloadThroughput, java.lang.Number 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()
static Command<java.util.List<Cookie>>
getAllCookies()
Returns all browser cookies.static Command<java.util.List<java.lang.String>>
getCertificate(java.lang.String origin)
Returns the DER-encoded certificate.static Command<java.util.List<Cookie>>
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<Network.GetResponseBodyResponse>
getResponseBody(RequestId requestId)
Returns content served for the given request.static Command<Network.GetResponseBodyForInterceptionResponse>
getResponseBodyForInterception(InterceptionId interceptionId)
Returns content served for the given currently intercepted request.static Event<LoadingFailed>
loadingFailed()
static Event<LoadingFinished>
loadingFinished()
static Command<java.lang.Void>
replayXHR(RequestId requestId)
This method sends a new XMLHttpRequest which is identical to the original one.static Event<RequestIntercepted>
requestIntercepted()
static Event<RequestId>
requestServedFromCache()
static Event<RequestWillBeSent>
requestWillBeSent()
static Event<RequestWillBeSentExtraInfo>
requestWillBeSentExtraInfo()
static Event<ResourceChangedPriority>
resourceChangedPriority()
static Event<ResponseReceived>
responseReceived()
static Event<ResponseReceivedExtraInfo>
responseReceivedExtraInfo()
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.static Command<java.lang.Void>
setBlockedURLs(java.util.List<java.lang.String> urls)
Blocks URLs from loading.static Command<java.lang.Void>
setBypassServiceWorker(java.lang.Boolean bypass)
Toggles ignoring of service worker for each request.static Command<java.lang.Void>
setCacheDisabled(java.lang.Boolean cacheDisabled)
Toggles ignoring cache for each request.static Command<java.lang.Boolean>
setCookie(java.lang.String name, java.lang.String value, java.util.Optional<java.lang.String> url, java.util.Optional<java.lang.String> domain, java.util.Optional<java.lang.String> path, java.util.Optional<java.lang.Boolean> secure, java.util.Optional<java.lang.Boolean> httpOnly, java.util.Optional<CookieSameSite> sameSite, java.util.Optional<TimeSinceEpoch> expires, java.util.Optional<CookiePriority> priority)
Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.static Command<java.lang.Void>
setCookies(java.util.List<CookieParam> cookies)
Sets given cookies.static Command<java.lang.Void>
setDataSizeLimitsForTest(java.lang.Integer maxTotalSize, java.lang.Integer maxResourceSize)
For testing.static Command<java.lang.Void>
setExtraHTTPHeaders(Headers 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)
Deprecated.static Command<java.lang.Void>
setUserAgentOverride(java.lang.String userAgent, java.util.Optional<java.lang.String> acceptLanguage, java.util.Optional<java.lang.String> platform, java.util.Optional<UserAgentMetadata> userAgentMetadata)
Allows overriding user agent with the given string.static Event<SignedExchangeReceived>
signedExchangeReceived()
static Command<StreamHandle>
takeResponseBodyForInterceptionAsStream(InterceptionId interceptionId)
Returns a handle to the stream representing the response body.static Event<WebSocketClosed>
webSocketClosed()
static Event<WebSocketCreated>
webSocketCreated()
static Event<WebSocketFrameError>
webSocketFrameError()
static Event<WebSocketFrameReceived>
webSocketFrameReceived()
static Event<WebSocketFrameSent>
webSocketFrameSent()
static Event<WebSocketHandshakeResponseReceived>
webSocketHandshakeResponseReceived()
static Event<WebSocketWillSendHandshakeRequest>
webSocketWillSendHandshakeRequest()
-
-
-
Method Detail
-
canClearBrowserCache
@Deprecated public static Command<java.lang.Boolean> canClearBrowserCache()
Deprecated.Tells whether clearing browser cache is supported.
-
canClearBrowserCookies
@Deprecated public static Command<java.lang.Boolean> canClearBrowserCookies()
Deprecated.Tells whether clearing browser cookies is supported.
-
canEmulateNetworkConditions
@Deprecated public static Command<java.lang.Boolean> canEmulateNetworkConditions()
Deprecated.Tells whether emulation of network conditions is supported.
-
clearBrowserCache
public static Command<java.lang.Void> clearBrowserCache()
Clears browser cache.
-
clearBrowserCookies
public static Command<java.lang.Void> clearBrowserCookies()
Clears browser cookies.
-
continueInterceptedRequest
@Beta @Deprecated 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<Headers> headers, java.util.Optional<AuthChallengeResponse> authChallengeResponse)
Deprecated.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. If a network fetch occurs as a result which encounters a redirect an additional Network.requestIntercepted event will be sent with the same InterceptionId. Deprecated, use Fetch.continueRequest, Fetch.fulfillRequest and Fetch.failRequest instead.
-
deleteCookies
public 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.
-
disable
public static Command<java.lang.Void> disable()
Disables network tracking, prevents network events from being sent to the client.
-
emulateNetworkConditions
public static Command<java.lang.Void> emulateNetworkConditions(java.lang.Boolean offline, java.lang.Number latency, java.lang.Number downloadThroughput, java.lang.Number uploadThroughput, java.util.Optional<ConnectionType> connectionType)
Activates emulation of network conditions.
-
enable
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)
Enables network tracking, network events will now be delivered to the client.
-
getAllCookies
public static Command<java.util.List<Cookie>> getAllCookies()
Returns all browser cookies. Depending on the backend support, will return detailed cookie information in the `cookies` field.
-
getCertificate
@Beta public static Command<java.util.List<java.lang.String>> getCertificate(java.lang.String origin)
Returns the DER-encoded certificate.
-
getCookies
public static Command<java.util.List<Cookie>> getCookies(java.util.Optional<java.util.List<java.lang.String>> urls)
Returns all browser cookies for the current URL. Depending on the backend support, will return detailed cookie information in the `cookies` field.
-
getResponseBody
public static Command<Network.GetResponseBodyResponse> getResponseBody(RequestId requestId)
Returns content served for the given request.
-
getRequestPostData
public static Command<java.lang.String> getRequestPostData(RequestId requestId)
Returns post data sent with the request. Returns an error when no data was sent with the request.
-
getResponseBodyForInterception
@Beta public static Command<Network.GetResponseBodyForInterceptionResponse> getResponseBodyForInterception(InterceptionId interceptionId)
Returns content served for the given currently intercepted request.
-
takeResponseBodyForInterceptionAsStream
@Beta public static Command<StreamHandle> takeResponseBodyForInterceptionAsStream(InterceptionId interceptionId)
Returns a handle to the stream representing the response body. Note that after this command, the intercepted request can't be continued as is -- you either need to cancel it or to provide the response body. The stream only supports sequential read, IO.read will fail if the position is specified.
-
replayXHR
@Beta public static Command<java.lang.Void> replayXHR(RequestId requestId)
This method sends a new XMLHttpRequest which is identical to the original one. The following parameters should be identical: method, url, async, request body, extra headers, withCredentials attribute, user, password.
-
searchInResponseBody
@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)
Searches for given string in response content.
-
setBlockedURLs
@Beta public static Command<java.lang.Void> setBlockedURLs(java.util.List<java.lang.String> urls)
Blocks URLs from loading.
-
setBypassServiceWorker
@Beta public static Command<java.lang.Void> setBypassServiceWorker(java.lang.Boolean bypass)
Toggles ignoring of service worker for each request.
-
setCacheDisabled
public static Command<java.lang.Void> setCacheDisabled(java.lang.Boolean cacheDisabled)
Toggles ignoring cache for each request. If `true`, cache will not be used.
-
setCookie
public static Command<java.lang.Boolean> setCookie(java.lang.String name, java.lang.String value, java.util.Optional<java.lang.String> url, java.util.Optional<java.lang.String> domain, java.util.Optional<java.lang.String> path, java.util.Optional<java.lang.Boolean> secure, java.util.Optional<java.lang.Boolean> httpOnly, java.util.Optional<CookieSameSite> sameSite, java.util.Optional<TimeSinceEpoch> expires, java.util.Optional<CookiePriority> priority)
Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.
-
setCookies
public static Command<java.lang.Void> setCookies(java.util.List<CookieParam> cookies)
Sets given cookies.
-
setDataSizeLimitsForTest
@Beta public static Command<java.lang.Void> setDataSizeLimitsForTest(java.lang.Integer maxTotalSize, java.lang.Integer maxResourceSize)
For testing.
-
setExtraHTTPHeaders
public static Command<java.lang.Void> setExtraHTTPHeaders(Headers headers)
Specifies whether to always send extra HTTP headers with the requests from this page.
-
setRequestInterception
@Beta @Deprecated public static Command<java.lang.Void> setRequestInterception(java.util.List<RequestPattern> patterns)
Deprecated.Sets the requests to intercept that match the provided patterns and optionally resource types. Deprecated, please use Fetch.enable instead.
-
setUserAgentOverride
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, java.util.Optional<UserAgentMetadata> userAgentMetadata)
Allows overriding user agent with the given string.
-
dataReceived
public static Event<DataReceived> dataReceived()
-
eventSourceMessageReceived
public static Event<EventSourceMessageReceived> eventSourceMessageReceived()
-
loadingFailed
public static Event<LoadingFailed> loadingFailed()
-
loadingFinished
public static Event<LoadingFinished> loadingFinished()
-
requestIntercepted
public static Event<RequestIntercepted> requestIntercepted()
-
requestWillBeSent
public static Event<RequestWillBeSent> requestWillBeSent()
-
resourceChangedPriority
public static Event<ResourceChangedPriority> resourceChangedPriority()
-
signedExchangeReceived
public static Event<SignedExchangeReceived> signedExchangeReceived()
-
responseReceived
public static Event<ResponseReceived> responseReceived()
-
webSocketClosed
public static Event<WebSocketClosed> webSocketClosed()
-
webSocketCreated
public static Event<WebSocketCreated> webSocketCreated()
-
webSocketFrameError
public static Event<WebSocketFrameError> webSocketFrameError()
-
webSocketFrameReceived
public static Event<WebSocketFrameReceived> webSocketFrameReceived()
-
webSocketFrameSent
public static Event<WebSocketFrameSent> webSocketFrameSent()
-
webSocketHandshakeResponseReceived
public static Event<WebSocketHandshakeResponseReceived> webSocketHandshakeResponseReceived()
-
webSocketWillSendHandshakeRequest
public static Event<WebSocketWillSendHandshakeRequest> webSocketWillSendHandshakeRequest()
-
requestWillBeSentExtraInfo
public static Event<RequestWillBeSentExtraInfo> requestWillBeSentExtraInfo()
-
responseReceivedExtraInfo
public static Event<ResponseReceivedExtraInfo> responseReceivedExtraInfo()
-
-