Class: Selenium::DevTools::V131::Network

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/devtools/v131/network.rb

Constant Summary collapse

EVENTS =
{
  data_received: 'dataReceived',
  event_source_message_received: 'eventSourceMessageReceived',
  loading_failed: 'loadingFailed',
  loading_finished: 'loadingFinished',
  request_intercepted: 'requestIntercepted',
  request_served_from_cache: 'requestServedFromCache',
  request_will_be_sent: 'requestWillBeSent',
  resource_changed_priority: 'resourceChangedPriority',
  signed_exchange_received: 'signedExchangeReceived',
  response_received: 'responseReceived',
  web_socket_closed: 'webSocketClosed',
  web_socket_created: 'webSocketCreated',
  web_socket_frame_error: 'webSocketFrameError',
  web_socket_frame_received: 'webSocketFrameReceived',
  web_socket_frame_sent: 'webSocketFrameSent',
  web_socket_handshake_response_received: 'webSocketHandshakeResponseReceived',
  web_socket_will_send_handshake_request: 'webSocketWillSendHandshakeRequest',
  web_transport_created: 'webTransportCreated',
  web_transport_connection_established: 'webTransportConnectionEstablished',
  web_transport_closed: 'webTransportClosed',
  request_will_be_sent_extra_info: 'requestWillBeSentExtraInfo',
  response_received_extra_info: 'responseReceivedExtraInfo',
  response_received_early_hints: 'responseReceivedEarlyHints',
  trust_token_operation_done: 'trustTokenOperationDone',
  policy_updated: 'policyUpdated',
  subresource_web_bundle_metadata_received: 'subresourceWebBundleMetadataReceived',
  subresource_web_bundle_metadata_error: 'subresourceWebBundleMetadataError',
  subresource_web_bundle_inner_response_parsed: 'subresourceWebBundleInnerResponseParsed',
  subresource_web_bundle_inner_response_error: 'subresourceWebBundleInnerResponseError',
  reporting_api_report_added: 'reportingApiReportAdded',
  reporting_api_report_updated: 'reportingApiReportUpdated',
  reporting_api_endpoints_changed_for_origin: 'reportingApiEndpointsChangedForOrigin',
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(devtools) ⇒ Network

Returns a new instance of Network.



60
61
62
# File 'lib/selenium/devtools/v131/network.rb', line 60

def initialize(devtools)
  @devtools = devtools
end

Instance Method Details

#can_clear_browser_cacheObject



78
79
80
# File 'lib/selenium/devtools/v131/network.rb', line 78

def can_clear_browser_cache
  @devtools.send_cmd('Network.canClearBrowserCache')
end

#can_clear_browser_cookiesObject



82
83
84
# File 'lib/selenium/devtools/v131/network.rb', line 82

def can_clear_browser_cookies
  @devtools.send_cmd('Network.canClearBrowserCookies')
end

#can_emulate_network_conditionsObject



86
87
88
# File 'lib/selenium/devtools/v131/network.rb', line 86

def can_emulate_network_conditions
  @devtools.send_cmd('Network.canEmulateNetworkConditions')
end

#clear_accepted_encodings_overrideObject



74
75
76
# File 'lib/selenium/devtools/v131/network.rb', line 74

def clear_accepted_encodings_override
  @devtools.send_cmd('Network.clearAcceptedEncodingsOverride')
end

#clear_browser_cacheObject



90
91
92
# File 'lib/selenium/devtools/v131/network.rb', line 90

def clear_browser_cache
  @devtools.send_cmd('Network.clearBrowserCache')
end

#clear_browser_cookiesObject



94
95
96
# File 'lib/selenium/devtools/v131/network.rb', line 94

def clear_browser_cookies
  @devtools.send_cmd('Network.clearBrowserCookies')
end

#continue_intercepted_request(interception_id:, error_reason: nil, raw_response: nil, url: nil, method: nil, post_data: nil, headers: nil, auth_challenge_response: nil) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
# File 'lib/selenium/devtools/v131/network.rb', line 98

def continue_intercepted_request(interception_id:, error_reason: nil, raw_response: nil, url: nil, method: nil, post_data: nil, headers: nil, auth_challenge_response: nil)
  @devtools.send_cmd('Network.continueInterceptedRequest',
                     interceptionId: interception_id,
                     errorReason: error_reason,
                     rawResponse: raw_response,
                     url: url,
                     method: method,
                     postData: post_data,
                     headers: headers,
                     authChallengeResponse: auth_challenge_response)
end

#delete_cookies(name:, url: nil, domain: nil, path: nil, partition_key: nil) ⇒ Object



110
111
112
113
114
115
116
117
# File 'lib/selenium/devtools/v131/network.rb', line 110

def delete_cookies(name:, url: nil, domain: nil, path: nil, partition_key: nil)
  @devtools.send_cmd('Network.deleteCookies',
                     name: name,
                     url: url,
                     domain: domain,
                     path: path,
                     partitionKey: partition_key)
end

#disableObject



119
120
121
# File 'lib/selenium/devtools/v131/network.rb', line 119

def disable
  @devtools.send_cmd('Network.disable')
end

#emulate_network_conditions(offline:, latency:, download_throughput:, upload_throughput:, connection_type: nil, packet_loss: nil, packet_queue_length: nil, packet_reordering: nil) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
# File 'lib/selenium/devtools/v131/network.rb', line 123

def emulate_network_conditions(offline:, latency:, download_throughput:, upload_throughput:, connection_type: nil, packet_loss: nil, packet_queue_length: nil, packet_reordering: nil)
  @devtools.send_cmd('Network.emulateNetworkConditions',
                     offline: offline,
                     latency: latency,
                     downloadThroughput: download_throughput,
                     uploadThroughput: upload_throughput,
                     connectionType: connection_type,
                     packetLoss: packet_loss,
                     packetQueueLength: packet_queue_length,
                     packetReordering: packet_reordering)
end

#enable(max_total_buffer_size: nil, max_resource_buffer_size: nil, max_post_data_size: nil) ⇒ Object



135
136
137
138
139
140
# File 'lib/selenium/devtools/v131/network.rb', line 135

def enable(max_total_buffer_size: nil, max_resource_buffer_size: nil, max_post_data_size: nil)
  @devtools.send_cmd('Network.enable',
                     maxTotalBufferSize: max_total_buffer_size,
                     maxResourceBufferSize: max_resource_buffer_size,
                     maxPostDataSize: max_post_data_size)
end

#enable_reporting_api(enable:) ⇒ Object



260
261
262
263
# File 'lib/selenium/devtools/v131/network.rb', line 260

def enable_reporting_api(enable:)
  @devtools.send_cmd('Network.enableReportingApi',
                     enable: enable)
end

#get_all_cookiesObject



142
143
144
# File 'lib/selenium/devtools/v131/network.rb', line 142

def get_all_cookies
  @devtools.send_cmd('Network.getAllCookies')
end

#get_certificate(origin:) ⇒ Object



146
147
148
149
# File 'lib/selenium/devtools/v131/network.rb', line 146

def get_certificate(origin:)
  @devtools.send_cmd('Network.getCertificate',
                     origin: origin)
end

#get_cookies(urls: nil) ⇒ Object



151
152
153
154
# File 'lib/selenium/devtools/v131/network.rb', line 151

def get_cookies(urls: nil)
  @devtools.send_cmd('Network.getCookies',
                     urls: urls)
end

#get_request_post_data(request_id:) ⇒ Object



161
162
163
164
# File 'lib/selenium/devtools/v131/network.rb', line 161

def get_request_post_data(request_id:)
  @devtools.send_cmd('Network.getRequestPostData',
                     requestId: request_id)
end

#get_response_body(request_id:) ⇒ Object



156
157
158
159
# File 'lib/selenium/devtools/v131/network.rb', line 156

def get_response_body(request_id:)
  @devtools.send_cmd('Network.getResponseBody',
                     requestId: request_id)
end

#get_response_body_for_interception(interception_id:) ⇒ Object



166
167
168
169
# File 'lib/selenium/devtools/v131/network.rb', line 166

def get_response_body_for_interception(interception_id:)
  @devtools.send_cmd('Network.getResponseBodyForInterception',
                     interceptionId: interception_id)
end

#get_security_isolation_status(frame_id: nil) ⇒ Object



255
256
257
258
# File 'lib/selenium/devtools/v131/network.rb', line 255

def get_security_isolation_status(frame_id: nil)
  @devtools.send_cmd('Network.getSecurityIsolationStatus',
                     frameId: frame_id)
end

#load_network_resource(frame_id: nil, url:, options:) ⇒ Object



265
266
267
268
269
270
# File 'lib/selenium/devtools/v131/network.rb', line 265

def load_network_resource(frame_id: nil, url:, options:)
  @devtools.send_cmd('Network.loadNetworkResource',
                     frameId: frame_id,
                     url: url,
                     options: options)
end

#on(event, &block) ⇒ Object



64
65
66
67
# File 'lib/selenium/devtools/v131/network.rb', line 64

def on(event, &block)
  event = EVENTS[event] if event.is_a?(Symbol)
  @devtools.callbacks["Network.#{event}"] << block
end

#replay_xhr(request_id:) ⇒ Object



176
177
178
179
# File 'lib/selenium/devtools/v131/network.rb', line 176

def replay_xhr(request_id:)
  @devtools.send_cmd('Network.replayXHR',
                     requestId: request_id)
end

#search_in_response_body(request_id:, query:, case_sensitive: nil, is_regex: nil) ⇒ Object



181
182
183
184
185
186
187
# File 'lib/selenium/devtools/v131/network.rb', line 181

def search_in_response_body(request_id:, query:, case_sensitive: nil, is_regex: nil)
  @devtools.send_cmd('Network.searchInResponseBody',
                     requestId: request_id,
                     query: query,
                     caseSensitive: case_sensitive,
                     isRegex: is_regex)
end

#set_accepted_encodings(encodings:) ⇒ Object



69
70
71
72
# File 'lib/selenium/devtools/v131/network.rb', line 69

def set_accepted_encodings(encodings:)
  @devtools.send_cmd('Network.setAcceptedEncodings',
                     encodings: encodings)
end

#set_attach_debug_stack(enabled:) ⇒ Object



232
233
234
235
# File 'lib/selenium/devtools/v131/network.rb', line 232

def set_attach_debug_stack(enabled:)
  @devtools.send_cmd('Network.setAttachDebugStack',
                     enabled: enabled)
end

#set_blocked_urls(urls:) ⇒ Object



189
190
191
192
# File 'lib/selenium/devtools/v131/network.rb', line 189

def set_blocked_urls(urls:)
  @devtools.send_cmd('Network.setBlockedURLs',
                     urls: urls)
end

#set_bypass_service_worker(bypass:) ⇒ Object



194
195
196
197
# File 'lib/selenium/devtools/v131/network.rb', line 194

def set_bypass_service_worker(bypass:)
  @devtools.send_cmd('Network.setBypassServiceWorker',
                     bypass: bypass)
end

#set_cache_disabled(cache_disabled:) ⇒ Object



199
200
201
202
# File 'lib/selenium/devtools/v131/network.rb', line 199

def set_cache_disabled(cache_disabled:)
  @devtools.send_cmd('Network.setCacheDisabled',
                     cacheDisabled: cache_disabled)
end


204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/selenium/devtools/v131/network.rb', line 204

def set_cookie(name:, value:, url: nil, domain: nil, path: nil, secure: nil, http_only: nil, same_site: nil, expires: nil, priority: nil, same_party: nil, source_scheme: nil, source_port: nil, partition_key: nil)
  @devtools.send_cmd('Network.setCookie',
                     name: name,
                     value: value,
                     url: url,
                     domain: domain,
                     path: path,
                     secure: secure,
                     httpOnly: http_only,
                     sameSite: same_site,
                     expires: expires,
                     priority: priority,
                     sameParty: same_party,
                     sourceScheme: source_scheme,
                     sourcePort: source_port,
                     partitionKey: partition_key)
end

#set_cookies(cookies:) ⇒ Object



222
223
224
225
# File 'lib/selenium/devtools/v131/network.rb', line 222

def set_cookies(cookies:)
  @devtools.send_cmd('Network.setCookies',
                     cookies: cookies)
end

#set_extra_http_headers(headers:) ⇒ Object



227
228
229
230
# File 'lib/selenium/devtools/v131/network.rb', line 227

def set_extra_http_headers(headers:)
  @devtools.send_cmd('Network.setExtraHTTPHeaders',
                     headers: headers)
end

#set_request_interception(patterns:) ⇒ Object



237
238
239
240
# File 'lib/selenium/devtools/v131/network.rb', line 237

def set_request_interception(patterns:)
  @devtools.send_cmd('Network.setRequestInterception',
                     patterns: patterns)
end

#set_user_agent_override(user_agent:, accept_language: nil, platform: nil, user_agent_metadata: nil) ⇒ Object



242
243
244
245
246
247
248
# File 'lib/selenium/devtools/v131/network.rb', line 242

def set_user_agent_override(user_agent:, accept_language: nil, platform: nil, user_agent_metadata: nil)
  @devtools.send_cmd('Network.setUserAgentOverride',
                     userAgent: user_agent,
                     acceptLanguage: accept_language,
                     platform: platform,
                     userAgentMetadata: )
end

#stream_resource_content(request_id:) ⇒ Object



250
251
252
253
# File 'lib/selenium/devtools/v131/network.rb', line 250

def stream_resource_content(request_id:)
  @devtools.send_cmd('Network.streamResourceContent',
                     requestId: request_id)
end

#take_response_body_for_interception_as_stream(interception_id:) ⇒ Object



171
172
173
174
# File 'lib/selenium/devtools/v131/network.rb', line 171

def take_response_body_for_interception_as_stream(interception_id:)
  @devtools.send_cmd('Network.takeResponseBodyForInterceptionAsStream',
                     interceptionId: interception_id)
end