Class: Selenium::DevTools::V128::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/devtools/v128/page.rb

Constant Summary collapse

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',
  load_event_fired: 'loadEventFired',
  navigated_within_document: 'navigatedWithinDocument',
  screencast_frame: 'screencastFrame',
  screencast_visibility_changed: 'screencastVisibilityChanged',
  window_open: 'windowOpen',
  compilation_cache_produced: 'compilationCacheProduced',
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(devtools) ⇒ Page

Returns a new instance of Page.



54
55
56
# File 'lib/selenium/devtools/v128/page.rb', line 54

def initialize(devtools)
  @devtools = devtools
end

Instance Method Details

#add_compilation_cache(url:, data:) ⇒ Object



367
368
369
370
371
# File 'lib/selenium/devtools/v128/page.rb', line 367

def add_compilation_cache(url:, data:)
  @devtools.send_cmd('Page.addCompilationCache',
                     url: url,
                     data: data)
end

#add_script_to_evaluate_on_load(script_source:) ⇒ Object



63
64
65
66
# File 'lib/selenium/devtools/v128/page.rb', line 63

def add_script_to_evaluate_on_load(script_source:)
  @devtools.send_cmd('Page.addScriptToEvaluateOnLoad',
                     scriptSource: script_source)
end

#add_script_to_evaluate_on_new_document(source:, world_name: nil, include_command_line_api: nil, run_immediately: nil) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/selenium/devtools/v128/page.rb', line 68

def add_script_to_evaluate_on_new_document(source:, world_name: nil, include_command_line_api: nil, run_immediately: nil)
  @devtools.send_cmd('Page.addScriptToEvaluateOnNewDocument',
                     source: source,
                     worldName: world_name,
                     includeCommandLineAPI: include_command_line_api,
                     runImmediately: run_immediately)
end

#bring_to_frontObject



76
77
78
# File 'lib/selenium/devtools/v128/page.rb', line 76

def bring_to_front
  @devtools.send_cmd('Page.bringToFront')
end

#capture_screenshot(format: nil, quality: nil, clip: nil, from_surface: nil, capture_beyond_viewport: nil, optimize_for_speed: nil) ⇒ Object



80
81
82
83
84
85
86
87
88
# File 'lib/selenium/devtools/v128/page.rb', line 80

def capture_screenshot(format: nil, quality: nil, clip: nil, from_surface: nil, capture_beyond_viewport: nil, optimize_for_speed: nil)
  @devtools.send_cmd('Page.captureScreenshot',
                     format: format,
                     quality: quality,
                     clip: clip,
                     fromSurface: from_surface,
                     captureBeyondViewport: capture_beyond_viewport,
                     optimizeForSpeed: optimize_for_speed)
end

#capture_snapshot(format: nil) ⇒ Object



90
91
92
93
# File 'lib/selenium/devtools/v128/page.rb', line 90

def capture_snapshot(format: nil)
  @devtools.send_cmd('Page.captureSnapshot',
                     format: format)
end

#clear_compilation_cacheObject



373
374
375
# File 'lib/selenium/devtools/v128/page.rb', line 373

def clear_compilation_cache
  @devtools.send_cmd('Page.clearCompilationCache')
end

#clear_device_metrics_overrideObject



95
96
97
# File 'lib/selenium/devtools/v128/page.rb', line 95

def clear_device_metrics_override
  @devtools.send_cmd('Page.clearDeviceMetricsOverride')
end

#clear_device_orientation_overrideObject



99
100
101
# File 'lib/selenium/devtools/v128/page.rb', line 99

def clear_device_orientation_override
  @devtools.send_cmd('Page.clearDeviceOrientationOverride')
end

#clear_geolocation_overrideObject



103
104
105
# File 'lib/selenium/devtools/v128/page.rb', line 103

def clear_geolocation_override
  @devtools.send_cmd('Page.clearGeolocationOverride')
end

#closeObject



349
350
351
# File 'lib/selenium/devtools/v128/page.rb', line 349

def close
  @devtools.send_cmd('Page.close')
end

#crashObject



345
346
347
# File 'lib/selenium/devtools/v128/page.rb', line 345

def crash
  @devtools.send_cmd('Page.crash')
end

#create_isolated_world(frame_id:, world_name: nil, grant_univeral_access: nil) ⇒ Object



107
108
109
110
111
112
# File 'lib/selenium/devtools/v128/page.rb', line 107

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


114
115
116
117
118
# File 'lib/selenium/devtools/v128/page.rb', line 114

def delete_cookie(cookie_name:, url:)
  @devtools.send_cmd('Page.deleteCookie',
                     cookieName: cookie_name,
                     url: url)
end

#disableObject



120
121
122
# File 'lib/selenium/devtools/v128/page.rb', line 120

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

#enableObject



124
125
126
# File 'lib/selenium/devtools/v128/page.rb', line 124

def enable
  @devtools.send_cmd('Page.enable')
end

#generate_test_report(message:, group: nil) ⇒ Object



387
388
389
390
391
# File 'lib/selenium/devtools/v128/page.rb', line 387

def generate_test_report(message:, group: nil)
  @devtools.send_cmd('Page.generateTestReport',
                     message: message,
                     group: group)
end

#get_ad_script_id(frame_id:) ⇒ Object



145
146
147
148
# File 'lib/selenium/devtools/v128/page.rb', line 145

def get_ad_script_id(frame_id:)
  @devtools.send_cmd('Page.getAdScriptId',
                     frameId: frame_id)
end

#get_app_idObject



141
142
143
# File 'lib/selenium/devtools/v128/page.rb', line 141

def get_app_id
  @devtools.send_cmd('Page.getAppId')
end

#get_app_manifest(manifest_id: nil) ⇒ Object



128
129
130
131
# File 'lib/selenium/devtools/v128/page.rb', line 128

def get_app_manifest(manifest_id: nil)
  @devtools.send_cmd('Page.getAppManifest',
                     manifestId: manifest_id)
end

#get_frame_treeObject



150
151
152
# File 'lib/selenium/devtools/v128/page.rb', line 150

def get_frame_tree
  @devtools.send_cmd('Page.getFrameTree')
end

#get_installability_errorsObject



133
134
135
# File 'lib/selenium/devtools/v128/page.rb', line 133

def get_installability_errors
  @devtools.send_cmd('Page.getInstallabilityErrors')
end

#get_layout_metricsObject



154
155
156
# File 'lib/selenium/devtools/v128/page.rb', line 154

def get_layout_metrics
  @devtools.send_cmd('Page.getLayoutMetrics')
end

#get_manifest_iconsObject



137
138
139
# File 'lib/selenium/devtools/v128/page.rb', line 137

def get_manifest_icons
  @devtools.send_cmd('Page.getManifestIcons')
end

#get_navigation_historyObject



158
159
160
# File 'lib/selenium/devtools/v128/page.rb', line 158

def get_navigation_history
  @devtools.send_cmd('Page.getNavigationHistory')
end

#get_origin_trials(frame_id:) ⇒ Object



263
264
265
266
# File 'lib/selenium/devtools/v128/page.rb', line 263

def get_origin_trials(frame_id:)
  @devtools.send_cmd('Page.getOriginTrials',
                     frameId: frame_id)
end

#get_permissions_policy_state(frame_id:) ⇒ Object



258
259
260
261
# File 'lib/selenium/devtools/v128/page.rb', line 258

def get_permissions_policy_state(frame_id:)
  @devtools.send_cmd('Page.getPermissionsPolicyState',
                     frameId: frame_id)
end

#get_resource_content(frame_id:, url:) ⇒ Object



166
167
168
169
170
# File 'lib/selenium/devtools/v128/page.rb', line 166

def get_resource_content(frame_id:, url:)
  @devtools.send_cmd('Page.getResourceContent',
                     frameId: frame_id,
                     url: url)
end

#get_resource_treeObject



172
173
174
# File 'lib/selenium/devtools/v128/page.rb', line 172

def get_resource_tree
  @devtools.send_cmd('Page.getResourceTree')
end

#handle_javascript_dialog(accept:, prompt_text: nil) ⇒ Object



176
177
178
179
180
# File 'lib/selenium/devtools/v128/page.rb', line 176

def handle_javascript_dialog(accept:, prompt_text: nil)
  @devtools.send_cmd('Page.handleJavaScriptDialog',
                     accept: accept,
                     promptText: prompt_text)
end


182
183
184
185
186
187
188
189
# File 'lib/selenium/devtools/v128/page.rb', line 182

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

#navigate_to_history_entry(entry_id:) ⇒ Object



191
192
193
194
# File 'lib/selenium/devtools/v128/page.rb', line 191

def navigate_to_history_entry(entry_id:)
  @devtools.send_cmd('Page.navigateToHistoryEntry',
                     entryId: entry_id)
end

#on(event, &block) ⇒ Object



58
59
60
61
# File 'lib/selenium/devtools/v128/page.rb', line 58

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


196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/selenium/devtools/v128/page.rb', line 196

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, generate_tagged_pdf: nil, generate_document_outline: 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,
                     generateTaggedPDF: generate_tagged_pdf,
                     generateDocumentOutline: generate_document_outline)
end

#produce_compilation_cache(scripts:) ⇒ Object



362
363
364
365
# File 'lib/selenium/devtools/v128/page.rb', line 362

def produce_compilation_cache(scripts:)
  @devtools.send_cmd('Page.produceCompilationCache',
                     scripts: scripts)
end

#reload(ignore_cache: nil, script_to_evaluate_on_load: nil, loader_id: nil) ⇒ Object



217
218
219
220
221
222
# File 'lib/selenium/devtools/v128/page.rb', line 217

def reload(ignore_cache: nil, script_to_evaluate_on_load: nil, loader_id: nil)
  @devtools.send_cmd('Page.reload',
                     ignoreCache: ignore_cache,
                     scriptToEvaluateOnLoad: script_to_evaluate_on_load,
                     loaderId: loader_id)
end

#remove_script_to_evaluate_on_load(identifier:) ⇒ Object



224
225
226
227
# File 'lib/selenium/devtools/v128/page.rb', line 224

def remove_script_to_evaluate_on_load(identifier:)
  @devtools.send_cmd('Page.removeScriptToEvaluateOnLoad',
                     identifier: identifier)
end

#remove_script_to_evaluate_on_new_document(identifier:) ⇒ Object



229
230
231
232
# File 'lib/selenium/devtools/v128/page.rb', line 229

def remove_script_to_evaluate_on_new_document(identifier:)
  @devtools.send_cmd('Page.removeScriptToEvaluateOnNewDocument',
                     identifier: identifier)
end

#reset_navigation_historyObject



162
163
164
# File 'lib/selenium/devtools/v128/page.rb', line 162

def reset_navigation_history
  @devtools.send_cmd('Page.resetNavigationHistory')
end

#screencast_frame_ack(session_id:) ⇒ Object



234
235
236
237
# File 'lib/selenium/devtools/v128/page.rb', line 234

def screencast_frame_ack(session_id:)
  @devtools.send_cmd('Page.screencastFrameAck',
                     sessionId: session_id)
end

#search_in_resource(frame_id:, url:, query:, case_sensitive: nil, is_regex: nil) ⇒ Object



239
240
241
242
243
244
245
246
# File 'lib/selenium/devtools/v128/page.rb', line 239

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

#set_ad_blocking_enabled(enabled:) ⇒ Object



248
249
250
251
# File 'lib/selenium/devtools/v128/page.rb', line 248

def set_ad_blocking_enabled(enabled:)
  @devtools.send_cmd('Page.setAdBlockingEnabled',
                     enabled: enabled)
end

#set_bypass_csp(enabled:) ⇒ Object



253
254
255
256
# File 'lib/selenium/devtools/v128/page.rb', line 253

def set_bypass_csp(enabled:)
  @devtools.send_cmd('Page.setBypassCSP',
                     enabled: enabled)
end

#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) ⇒ Object



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/selenium/devtools/v128/page.rb', line 268

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

#set_device_orientation_override(alpha:, beta:, gamma:) ⇒ Object



284
285
286
287
288
289
# File 'lib/selenium/devtools/v128/page.rb', line 284

def set_device_orientation_override(alpha:, beta:, gamma:)
  @devtools.send_cmd('Page.setDeviceOrientationOverride',
                     alpha: alpha,
                     beta: beta,
                     gamma: gamma)
end

#set_document_content(frame_id:, html:) ⇒ Object



302
303
304
305
306
# File 'lib/selenium/devtools/v128/page.rb', line 302

def set_document_content(frame_id:, html:)
  @devtools.send_cmd('Page.setDocumentContent',
                     frameId: frame_id,
                     html: html)
end

#set_download_behavior(behavior:, download_path: nil) ⇒ Object



308
309
310
311
312
# File 'lib/selenium/devtools/v128/page.rb', line 308

def set_download_behavior(behavior:, download_path: nil)
  @devtools.send_cmd('Page.setDownloadBehavior',
                     behavior: behavior,
                     downloadPath: download_path)
end

#set_font_families(font_families:, for_scripts: nil) ⇒ Object



291
292
293
294
295
# File 'lib/selenium/devtools/v128/page.rb', line 291

def set_font_families(font_families:, for_scripts: nil)
  @devtools.send_cmd('Page.setFontFamilies',
                     fontFamilies: font_families,
                     forScripts: for_scripts)
end

#set_font_sizes(font_sizes:) ⇒ Object



297
298
299
300
# File 'lib/selenium/devtools/v128/page.rb', line 297

def set_font_sizes(font_sizes:)
  @devtools.send_cmd('Page.setFontSizes',
                     fontSizes: font_sizes)
end

#set_geolocation_override(latitude: nil, longitude: nil, accuracy: nil) ⇒ Object



314
315
316
317
318
319
# File 'lib/selenium/devtools/v128/page.rb', line 314

def set_geolocation_override(latitude: nil, longitude: nil, accuracy: nil)
  @devtools.send_cmd('Page.setGeolocationOverride',
                     latitude: latitude,
                     longitude: longitude,
                     accuracy: accuracy)
end

#set_intercept_file_chooser_dialog(enabled:) ⇒ Object



397
398
399
400
# File 'lib/selenium/devtools/v128/page.rb', line 397

def set_intercept_file_chooser_dialog(enabled:)
  @devtools.send_cmd('Page.setInterceptFileChooserDialog',
                     enabled: enabled)
end

#set_lifecycle_events_enabled(enabled:) ⇒ Object



321
322
323
324
# File 'lib/selenium/devtools/v128/page.rb', line 321

def set_lifecycle_events_enabled(enabled:)
  @devtools.send_cmd('Page.setLifecycleEventsEnabled',
                     enabled: enabled)
end

#set_prerendering_allowed(is_allowed:) ⇒ Object



402
403
404
405
# File 'lib/selenium/devtools/v128/page.rb', line 402

def set_prerendering_allowed(is_allowed:)
  @devtools.send_cmd('Page.setPrerenderingAllowed',
                     isAllowed: is_allowed)
end

#set_rph_registration_mode(mode:) ⇒ Object



382
383
384
385
# File 'lib/selenium/devtools/v128/page.rb', line 382

def set_rph_registration_mode(mode:)
  @devtools.send_cmd('Page.setRPHRegistrationMode',
                     mode: mode)
end

#set_spc_transaction_mode(mode:) ⇒ Object



377
378
379
380
# File 'lib/selenium/devtools/v128/page.rb', line 377

def set_spc_transaction_mode(mode:)
  @devtools.send_cmd('Page.setSPCTransactionMode',
                     mode: mode)
end

#set_touch_emulation_enabled(enabled:, configuration: nil) ⇒ Object



326
327
328
329
330
# File 'lib/selenium/devtools/v128/page.rb', line 326

def set_touch_emulation_enabled(enabled:, configuration: nil)
  @devtools.send_cmd('Page.setTouchEmulationEnabled',
                     enabled: enabled,
                     configuration: configuration)
end

#set_web_lifecycle_state(state:) ⇒ Object



353
354
355
356
# File 'lib/selenium/devtools/v128/page.rb', line 353

def set_web_lifecycle_state(state:)
  @devtools.send_cmd('Page.setWebLifecycleState',
                     state: state)
end

#start_screencast(format: nil, quality: nil, max_width: nil, max_height: nil, every_nth_frame: nil) ⇒ Object



332
333
334
335
336
337
338
339
# File 'lib/selenium/devtools/v128/page.rb', line 332

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

#stop_loadingObject



341
342
343
# File 'lib/selenium/devtools/v128/page.rb', line 341

def stop_loading
  @devtools.send_cmd('Page.stopLoading')
end

#stop_screencastObject



358
359
360
# File 'lib/selenium/devtools/v128/page.rb', line 358

def stop_screencast
  @devtools.send_cmd('Page.stopScreencast')
end

#wait_for_debuggerObject



393
394
395
# File 'lib/selenium/devtools/v128/page.rb', line 393

def wait_for_debugger
  @devtools.send_cmd('Page.waitForDebugger')
end