# frozen_string_literal: true # Licensed to the Software Freedom Conservancy (SFC) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The SFC licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # This file is automatically generated. Any changes will be lost! module Selenium module WebDriver class DevTools def network @network ||= V87::Network.new(self) end module V87 class Network 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', request_will_be_sent_extra_info: 'requestWillBeSentExtraInfo', response_received_extra_info: 'responseReceivedExtraInfo' }.freeze def initialize(devtools) @devtools = devtools end def on(event, &block) event = EVENTS[event] if event.is_a?(Symbol) @devtools.callbacks["Network.#{event}"] << block end def can_clear_browser_cache @devtools.send_cmd('Network.canClearBrowserCache') end def can_clear_browser_cookies @devtools.send_cmd('Network.canClearBrowserCookies') end def can_emulate_network_conditions @devtools.send_cmd('Network.canEmulateNetworkConditions') end def clear_browser_cache @devtools.send_cmd('Network.clearBrowserCache') end def clear_browser_cookies @devtools.send_cmd('Network.clearBrowserCookies') end 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 def delete_cookies(name:, url: nil, domain: nil, path: nil) @devtools.send_cmd('Network.deleteCookies', name: name, url: url, domain: domain, path: path) end def disable @devtools.send_cmd('Network.disable') end def emulate_network_conditions(offline:, latency:, download_throughput:, upload_throughput:, connection_type: nil) @devtools.send_cmd('Network.emulateNetworkConditions', offline: offline, latency: latency, downloadThroughput: download_throughput, uploadThroughput: upload_throughput, connectionType: connection_type) end 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 def get_all_cookies @devtools.send_cmd('Network.getAllCookies') end def get_certificate(origin:) @devtools.send_cmd('Network.getCertificate', origin: origin) end def get_cookies(urls: nil) @devtools.send_cmd('Network.getCookies', urls: urls) end def get_response_body(request_id:) @devtools.send_cmd('Network.getResponseBody', requestId: request_id) end def get_request_post_data(request_id:) @devtools.send_cmd('Network.getRequestPostData', requestId: request_id) end def get_response_body_for_interception(interception_id:) @devtools.send_cmd('Network.getResponseBodyForInterception', interceptionId: interception_id) end def take_response_body_for_interception_as_stream(interception_id:) @devtools.send_cmd('Network.takeResponseBodyForInterceptionAsStream', interceptionId: interception_id) end def replay_xhr(request_id:) @devtools.send_cmd('Network.replayXHR', requestId: request_id) end 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 def set_blocked_urls(urls:) @devtools.send_cmd('Network.setBlockedURLs', urls: urls) end def set_bypass_service_worker(bypass:) @devtools.send_cmd('Network.setBypassServiceWorker', bypass: bypass) end def set_cache_disabled(cache_disabled:) @devtools.send_cmd('Network.setCacheDisabled', cacheDisabled: cache_disabled) end def set_cookie(name:, value:, url: nil, domain: nil, path: nil, secure: nil, http_only: nil, same_site: nil, expires: nil, priority: 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) end def set_cookies(cookies:) @devtools.send_cmd('Network.setCookies', cookies: cookies) end def set_data_size_limits_for_test(max_total_size:, max_resource_size:) @devtools.send_cmd('Network.setDataSizeLimitsForTest', maxTotalSize: max_total_size, maxResourceSize: max_resource_size) end def set_extra_http_headers(headers:) @devtools.send_cmd('Network.setExtraHTTPHeaders', headers: headers) end def set_attach_debug_header(enabled:) @devtools.send_cmd('Network.setAttachDebugHeader', enabled: enabled) end def set_request_interception(patterns:) @devtools.send_cmd('Network.setRequestInterception', patterns: patterns) end 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: user_agent_metadata) end def get_security_isolation_status(frame_id: nil) @devtools.send_cmd('Network.getSecurityIsolationStatus', frameId: frame_id) end def load_network_resource(frame_id:, url:, options:) @devtools.send_cmd('Network.loadNetworkResource', frameId: frame_id, url: url, options: options) end end # V87 end # Network end # DevTools end # WebDriver end # Selenium