# 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 DevTools module V105 class Page EVENTS = { dom_content_event_fired: 'domContentEventFired', file_chooser_opened: 'fileChooserOpened', frame_attached: 'frameAttached', frame_cleared_scheduled_navigation: 'frameClearedScheduledNavigation', frame_detached: 'frameDetached', frame_navigated: 'frameNavigated', document_opened: 'documentOpened', frame_resized: 'frameResized', frame_requested_navigation: 'frameRequestedNavigation', frame_scheduled_navigation: 'frameScheduledNavigation', frame_started_loading: 'frameStartedLoading', frame_stopped_loading: 'frameStoppedLoading', download_will_begin: 'downloadWillBegin', download_progress: 'downloadProgress', interstitial_hidden: 'interstitialHidden', interstitial_shown: 'interstitialShown', javascript_dialog_closed: 'javascriptDialogClosed', javascript_dialog_opening: 'javascriptDialogOpening', lifecycle_event: 'lifecycleEvent', back_forward_cache_not_used: 'backForwardCacheNotUsed', prerender_attempt_completed: 'prerenderAttemptCompleted', load_event_fired: 'loadEventFired', navigated_within_document: 'navigatedWithinDocument', screencast_frame: 'screencastFrame', screencast_visibility_changed: 'screencastVisibilityChanged', window_open: 'windowOpen', compilation_cache_produced: 'compilationCacheProduced', }.freeze def initialize(devtools) @devtools = devtools end def on(event, &block) event = EVENTS[event] if event.is_a?(Symbol) @devtools.callbacks["Page.#{event}"] << block end def add_script_to_evaluate_on_load(script_source:) @devtools.send_cmd('Page.addScriptToEvaluateOnLoad', scriptSource: script_source) end def add_script_to_evaluate_on_new_document(source:, world_name: nil, include_command_line_api: nil) @devtools.send_cmd('Page.addScriptToEvaluateOnNewDocument', source: source, worldName: world_name, includeCommandLineAPI: include_command_line_api) end def bring_to_front @devtools.send_cmd('Page.bringToFront') end def capture_screenshot(format: nil, quality: nil, clip: nil, from_surface: nil, capture_beyond_viewport: nil) @devtools.send_cmd('Page.captureScreenshot', format: format, quality: quality, clip: clip, fromSurface: from_surface, captureBeyondViewport: capture_beyond_viewport) end def capture_snapshot(format: nil) @devtools.send_cmd('Page.captureSnapshot', format: format) end def clear_device_metrics_override @devtools.send_cmd('Page.clearDeviceMetricsOverride') end def clear_device_orientation_override @devtools.send_cmd('Page.clearDeviceOrientationOverride') end def clear_geolocation_override @devtools.send_cmd('Page.clearGeolocationOverride') end def create_isolated_world(frame_id:, world_name: nil, grant_univeral_access: nil) @devtools.send_cmd('Page.createIsolatedWorld', frameId: frame_id, worldName: world_name, grantUniveralAccess: grant_univeral_access) end def delete_cookie(cookie_name:, url:) @devtools.send_cmd('Page.deleteCookie', cookieName: cookie_name, url: url) end def disable @devtools.send_cmd('Page.disable') end def enable @devtools.send_cmd('Page.enable') end def get_app_manifest @devtools.send_cmd('Page.getAppManifest') end def get_installability_errors @devtools.send_cmd('Page.getInstallabilityErrors') end def get_manifest_icons @devtools.send_cmd('Page.getManifestIcons') end def get_app_id @devtools.send_cmd('Page.getAppId') end def get_cookies @devtools.send_cmd('Page.getCookies') end def get_frame_tree @devtools.send_cmd('Page.getFrameTree') end def get_layout_metrics @devtools.send_cmd('Page.getLayoutMetrics') end def get_navigation_history @devtools.send_cmd('Page.getNavigationHistory') end def reset_navigation_history @devtools.send_cmd('Page.resetNavigationHistory') end def get_resource_content(frame_id:, url:) @devtools.send_cmd('Page.getResourceContent', frameId: frame_id, url: url) end def get_resource_tree @devtools.send_cmd('Page.getResourceTree') end def handle_javascript_dialog(accept:, prompt_text: nil) @devtools.send_cmd('Page.handleJavaScriptDialog', accept: accept, promptText: prompt_text) end def navigate(url:, referrer: nil, transition_type: nil, frame_id: nil, referrer_policy: nil) @devtools.send_cmd('Page.navigate', url: url, referrer: referrer, transitionType: transition_type, frameId: frame_id, referrerPolicy: referrer_policy) end def navigate_to_history_entry(entry_id:) @devtools.send_cmd('Page.navigateToHistoryEntry', entryId: entry_id) end def print_to_pdf(landscape: nil, display_header_footer: nil, print_background: nil, scale: nil, paper_width: nil, paper_height: nil, margin_top: nil, margin_bottom: nil, margin_left: nil, margin_right: nil, page_ranges: nil, header_template: nil, footer_template: nil, prefer_css_page_size: nil, transfer_mode: nil) @devtools.send_cmd('Page.printToPDF', landscape: landscape, displayHeaderFooter: display_header_footer, printBackground: print_background, scale: scale, paperWidth: paper_width, paperHeight: paper_height, marginTop: margin_top, marginBottom: margin_bottom, marginLeft: margin_left, marginRight: margin_right, pageRanges: page_ranges, headerTemplate: header_template, footerTemplate: footer_template, preferCSSPageSize: prefer_css_page_size, transferMode: transfer_mode) end def reload(ignore_cache: nil, script_to_evaluate_on_load: nil) @devtools.send_cmd('Page.reload', ignoreCache: ignore_cache, scriptToEvaluateOnLoad: script_to_evaluate_on_load) end def remove_script_to_evaluate_on_load(identifier:) @devtools.send_cmd('Page.removeScriptToEvaluateOnLoad', identifier: identifier) end def remove_script_to_evaluate_on_new_document(identifier:) @devtools.send_cmd('Page.removeScriptToEvaluateOnNewDocument', identifier: identifier) end def screencast_frame_ack(session_id:) @devtools.send_cmd('Page.screencastFrameAck', sessionId: session_id) end def search_in_resource(frame_id:, url:, query:, case_sensitive: nil, is_regex: nil) @devtools.send_cmd('Page.searchInResource', frameId: frame_id, url: url, query: query, caseSensitive: case_sensitive, isRegex: is_regex) end def set_ad_blocking_enabled(enabled:) @devtools.send_cmd('Page.setAdBlockingEnabled', enabled: enabled) end def set_bypass_csp(enabled:) @devtools.send_cmd('Page.setBypassCSP', enabled: enabled) end def get_permissions_policy_state(frame_id:) @devtools.send_cmd('Page.getPermissionsPolicyState', frameId: frame_id) end def get_origin_trials(frame_id:) @devtools.send_cmd('Page.getOriginTrials', frameId: frame_id) end def set_device_metrics_override(width:, height:, device_scale_factor:, mobile:, scale: nil, screen_width: nil, screen_height: nil, position_x: nil, position_y: nil, dont_set_visible_size: nil, screen_orientation: nil, viewport: nil) @devtools.send_cmd('Page.setDeviceMetricsOverride', width: width, height: height, deviceScaleFactor: device_scale_factor, mobile: mobile, scale: scale, screenWidth: screen_width, screenHeight: screen_height, positionX: position_x, positionY: position_y, dontSetVisibleSize: dont_set_visible_size, screenOrientation: screen_orientation, viewport: viewport) end def set_device_orientation_override(alpha:, beta:, gamma:) @devtools.send_cmd('Page.setDeviceOrientationOverride', alpha: alpha, beta: beta, gamma: gamma) end def set_font_families(font_families:, for_scripts: nil) @devtools.send_cmd('Page.setFontFamilies', fontFamilies: font_families, forScripts: for_scripts) end def set_font_sizes(font_sizes:) @devtools.send_cmd('Page.setFontSizes', fontSizes: font_sizes) end def set_document_content(frame_id:, html:) @devtools.send_cmd('Page.setDocumentContent', frameId: frame_id, html: html) end def set_download_behavior(behavior:, download_path: nil) @devtools.send_cmd('Page.setDownloadBehavior', behavior: behavior, downloadPath: download_path) end def set_geolocation_override(latitude: nil, longitude: nil, accuracy: nil) @devtools.send_cmd('Page.setGeolocationOverride', latitude: latitude, longitude: longitude, accuracy: accuracy) end def set_lifecycle_events_enabled(enabled:) @devtools.send_cmd('Page.setLifecycleEventsEnabled', enabled: enabled) end def set_touch_emulation_enabled(enabled:, configuration: nil) @devtools.send_cmd('Page.setTouchEmulationEnabled', enabled: enabled, configuration: configuration) end def start_screencast(format: nil, quality: nil, max_width: nil, max_height: nil, every_nth_frame: nil) @devtools.send_cmd('Page.startScreencast', format: format, quality: quality, maxWidth: max_width, maxHeight: max_height, everyNthFrame: every_nth_frame) end def stop_loading @devtools.send_cmd('Page.stopLoading') end def crash @devtools.send_cmd('Page.crash') end def close @devtools.send_cmd('Page.close') end def set_web_lifecycle_state(state:) @devtools.send_cmd('Page.setWebLifecycleState', state: state) end def stop_screencast @devtools.send_cmd('Page.stopScreencast') end def produce_compilation_cache(scripts:) @devtools.send_cmd('Page.produceCompilationCache', scripts: scripts) end def add_compilation_cache(url:, data:) @devtools.send_cmd('Page.addCompilationCache', url: url, data: data) end def clear_compilation_cache @devtools.send_cmd('Page.clearCompilationCache') end def set_spc_transaction_mode(mode:) @devtools.send_cmd('Page.setSPCTransactionMode', mode: mode) end def generate_test_report(message:, group: nil) @devtools.send_cmd('Page.generateTestReport', message: message, group: group) end def wait_for_debugger @devtools.send_cmd('Page.waitForDebugger') end def set_intercept_file_chooser_dialog(enabled:) @devtools.send_cmd('Page.setInterceptFileChooserDialog', enabled: enabled) end end # Page end # V105 end # DevTools end # Selenium