Class: Selenium::DevTools::V130::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/devtools/v130/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_subtree_will_be_detached: 'frameSubtreeWillBeDetached',
  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.



55
56
57
# File 'lib/selenium/devtools/v130/page.rb', line 55

def initialize(devtools)
  @devtools = devtools
end

Instance Method Details

#add_compilation_cache(url:, data:) ⇒ Object



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

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



64
65
66
67
# File 'lib/selenium/devtools/v130/page.rb', line 64

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



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

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



77
78
79
# File 'lib/selenium/devtools/v130/page.rb', line 77

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



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

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



91
92
93
94
# File 'lib/selenium/devtools/v130/page.rb', line 91

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

#clear_compilation_cacheObject



374
375
376
# File 'lib/selenium/devtools/v130/page.rb', line 374

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

#clear_device_metrics_overrideObject



96
97
98
# File 'lib/selenium/devtools/v130/page.rb', line 96

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

#clear_device_orientation_overrideObject



100
101
102
# File 'lib/selenium/devtools/v130/page.rb', line 100

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

#clear_geolocation_overrideObject



104
105
106
# File 'lib/selenium/devtools/v130/page.rb', line 104

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

#closeObject



350
351
352
# File 'lib/selenium/devtools/v130/page.rb', line 350

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

#crashObject



346
347
348
# File 'lib/selenium/devtools/v130/page.rb', line 346

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

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



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

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


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

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

#disableObject



121
122
123
# File 'lib/selenium/devtools/v130/page.rb', line 121

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

#enableObject



125
126
127
# File 'lib/selenium/devtools/v130/page.rb', line 125

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

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



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

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

#get_ad_script_id(frame_id:) ⇒ Object



146
147
148
149
# File 'lib/selenium/devtools/v130/page.rb', line 146

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

#get_app_idObject



142
143
144
# File 'lib/selenium/devtools/v130/page.rb', line 142

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

#get_app_manifest(manifest_id: nil) ⇒ Object



129
130
131
132
# File 'lib/selenium/devtools/v130/page.rb', line 129

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

#get_frame_treeObject



151
152
153
# File 'lib/selenium/devtools/v130/page.rb', line 151

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

#get_installability_errorsObject



134
135
136
# File 'lib/selenium/devtools/v130/page.rb', line 134

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

#get_layout_metricsObject



155
156
157
# File 'lib/selenium/devtools/v130/page.rb', line 155

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

#get_manifest_iconsObject



138
139
140
# File 'lib/selenium/devtools/v130/page.rb', line 138

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

#get_navigation_historyObject



159
160
161
# File 'lib/selenium/devtools/v130/page.rb', line 159

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

#get_origin_trials(frame_id:) ⇒ Object



264
265
266
267
# File 'lib/selenium/devtools/v130/page.rb', line 264

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

#get_permissions_policy_state(frame_id:) ⇒ Object



259
260
261
262
# File 'lib/selenium/devtools/v130/page.rb', line 259

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

#get_resource_content(frame_id:, url:) ⇒ Object



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

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

#get_resource_treeObject



173
174
175
# File 'lib/selenium/devtools/v130/page.rb', line 173

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

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



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

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


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

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



192
193
194
195
# File 'lib/selenium/devtools/v130/page.rb', line 192

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

#on(event, &block) ⇒ Object



59
60
61
62
# File 'lib/selenium/devtools/v130/page.rb', line 59

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


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

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



363
364
365
366
# File 'lib/selenium/devtools/v130/page.rb', line 363

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



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

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



225
226
227
228
# File 'lib/selenium/devtools/v130/page.rb', line 225

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



230
231
232
233
# File 'lib/selenium/devtools/v130/page.rb', line 230

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

#reset_navigation_historyObject



163
164
165
# File 'lib/selenium/devtools/v130/page.rb', line 163

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

#screencast_frame_ack(session_id:) ⇒ Object



235
236
237
238
# File 'lib/selenium/devtools/v130/page.rb', line 235

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



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

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



249
250
251
252
# File 'lib/selenium/devtools/v130/page.rb', line 249

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

#set_bypass_csp(enabled:) ⇒ Object



254
255
256
257
# File 'lib/selenium/devtools/v130/page.rb', line 254

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



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

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



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

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



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

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



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

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



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

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



298
299
300
301
# File 'lib/selenium/devtools/v130/page.rb', line 298

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



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

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



398
399
400
401
# File 'lib/selenium/devtools/v130/page.rb', line 398

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

#set_lifecycle_events_enabled(enabled:) ⇒ Object



322
323
324
325
# File 'lib/selenium/devtools/v130/page.rb', line 322

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

#set_prerendering_allowed(is_allowed:) ⇒ Object



403
404
405
406
# File 'lib/selenium/devtools/v130/page.rb', line 403

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

#set_rph_registration_mode(mode:) ⇒ Object



383
384
385
386
# File 'lib/selenium/devtools/v130/page.rb', line 383

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

#set_spc_transaction_mode(mode:) ⇒ Object



378
379
380
381
# File 'lib/selenium/devtools/v130/page.rb', line 378

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

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



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

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

#set_web_lifecycle_state(state:) ⇒ Object



354
355
356
357
# File 'lib/selenium/devtools/v130/page.rb', line 354

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



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

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



342
343
344
# File 'lib/selenium/devtools/v130/page.rb', line 342

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

#stop_screencastObject



359
360
361
# File 'lib/selenium/devtools/v130/page.rb', line 359

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

#wait_for_debuggerObject



394
395
396
# File 'lib/selenium/devtools/v130/page.rb', line 394

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