Class: Selenium::WebDriver::Remote::Bridge Private
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Remote::Bridge
- Includes:
- Atoms
- Defined in:
- rb/lib/selenium/webdriver/remote/bridge/commands.rb,
rb/lib/selenium/webdriver/remote/bridge.rb,
rb/lib/selenium/webdriver/remote/bridge/locator_converter.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Direct Known Subclasses
Defined Under Namespace
Classes: LocatorConverter
Constant Summary collapse
- PORT =
4444
- QUIT_ERRORS =
[IOError].freeze
- COMMANDS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ status: [:get, 'status'], # # session handling # new_session: [:post, 'session'], delete_session: [:delete, 'session/:session_id'], # # basic driver # get: [:post, 'session/:session_id/url'], get_current_url: [:get, 'session/:session_id/url'], back: [:post, 'session/:session_id/back'], forward: [:post, 'session/:session_id/forward'], refresh: [:post, 'session/:session_id/refresh'], get_title: [:get, 'session/:session_id/title'], # # window and Frame handling # get_window_handle: [:get, 'session/:session_id/window'], new_window: [:post, 'session/:session_id/window/new'], close_window: [:delete, 'session/:session_id/window'], switch_to_window: [:post, 'session/:session_id/window'], get_window_handles: [:get, 'session/:session_id/window/handles'], fullscreen_window: [:post, 'session/:session_id/window/fullscreen'], minimize_window: [:post, 'session/:session_id/window/minimize'], maximize_window: [:post, 'session/:session_id/window/maximize'], set_window_rect: [:post, 'session/:session_id/window/rect'], get_window_rect: [:get, 'session/:session_id/window/rect'], switch_to_frame: [:post, 'session/:session_id/frame'], switch_to_parent_frame: [:post, 'session/:session_id/frame/parent'], # # element # find_element: [:post, 'session/:session_id/element'], find_elements: [:post, 'session/:session_id/elements'], find_child_element: [:post, 'session/:session_id/element/:id/element'], find_child_elements: [:post, 'session/:session_id/element/:id/elements'], find_shadow_child_element: [:post, 'session/:session_id/shadow/:id/element'], find_shadow_child_elements: [:post, 'session/:session_id/shadow/:id/elements'], get_active_element: [:get, 'session/:session_id/element/active'], get_element_shadow_root: [:get, 'session/:session_id/element/:id/shadow'], is_element_selected: [:get, 'session/:session_id/element/:id/selected'], get_element_attribute: [:get, 'session/:session_id/element/:id/attribute/:name'], get_element_property: [:get, 'session/:session_id/element/:id/property/:name'], get_element_css_value: [:get, 'session/:session_id/element/:id/css/:property_name'], get_element_aria_role: [:get, 'session/:session_id/element/:id/computedrole'], get_element_aria_label: [:get, 'session/:session_id/element/:id/computedlabel'], get_element_text: [:get, 'session/:session_id/element/:id/text'], get_element_tag_name: [:get, 'session/:session_id/element/:id/name'], get_element_rect: [:get, 'session/:session_id/element/:id/rect'], is_element_enabled: [:get, 'session/:session_id/element/:id/enabled'], # # document handling # get_page_source: [:get, 'session/:session_id/source'], execute_script: [:post, 'session/:session_id/execute/sync'], execute_async_script: [:post, 'session/:session_id/execute/async'], # # cookies # get_all_cookies: [:get, 'session/:session_id/cookie'], get_cookie: [:get, 'session/:session_id/cookie/:name'], add_cookie: [:post, 'session/:session_id/cookie'], delete_cookie: [:delete, 'session/:session_id/cookie/:name'], delete_all_cookies: [:delete, 'session/:session_id/cookie'], # # timeouts # get_timeouts: [:get, 'session/:session_id/timeouts'], set_timeout: [:post, 'session/:session_id/timeouts'], # # actions # actions: [:post, 'session/:session_id/actions'], release_actions: [:delete, 'session/:session_id/actions'], print_page: [:post, 'session/:session_id/print'], # # Element Operations # element_click: [:post, 'session/:session_id/element/:id/click'], element_clear: [:post, 'session/:session_id/element/:id/clear'], element_send_keys: [:post, 'session/:session_id/element/:id/value'], # # alerts # dismiss_alert: [:post, 'session/:session_id/alert/dismiss'], accept_alert: [:post, 'session/:session_id/alert/accept'], get_alert_text: [:get, 'session/:session_id/alert/text'], send_alert_text: [:post, 'session/:session_id/alert/text'], # # screenshot # take_screenshot: [:get, 'session/:session_id/screenshot'], take_element_screenshot: [:get, 'session/:session_id/element/:id/screenshot'], # # virtual-authenticator # add_virtual_authenticator: [:post, 'session/:session_id/webauthn/authenticator'], remove_virtual_authenticator: [:delete, 'session/:session_id/webauthn/authenticator/:authenticatorId'], add_credential: [:post, 'session/:session_id/webauthn/authenticator/:authenticatorId/credential'], get_credentials: [:get, 'session/:session_id/webauthn/authenticator/:authenticatorId/credentials'], remove_credential: [:delete, 'session/:session_id/webauthn/authenticator/:authenticatorId/credentials/:credentialId'], remove_all_credentials: [:delete, 'session/:session_id/webauthn/authenticator/:authenticatorId/credentials'], set_user_verified: [:post, 'session/:session_id/webauthn/authenticator/:authenticatorId/uv'], # # federated-credential management # get_fedcm_title: [:get, 'session/:session_id/fedcm/gettitle'], get_fedcm_dialog_type: [:get, 'session/:session_id/fedcm/getdialogtype'], get_fedcm_account_list: [:get, 'session/:session_id/fedcm/accountlist'], click_fedcm_dialog_button: [:post, 'session/:session_id/fedcm/clickdialogbutton'], cancel_fedcm_dialog: [:post, 'session/:session_id/fedcm/canceldialog'], select_fedcm_account: [:post, 'session/:session_id/fedcm/selectaccount'], set_fedcm_delay: [:post, 'session/:session_id/fedcm/setdelayenabled'], reset_fedcm_cooldown: [:post, 'session/:session_id/fedcm/resetcooldown'] }.freeze
Class Attribute Summary collapse
- .element_class ⇒ Object
-
.extra_commands ⇒ Object
readonly
Returns the value of attribute extra_commands.
- .locator_converter ⇒ Object
Instance Attribute Summary collapse
-
#capabilities ⇒ Object
readonly
Returns the value of attribute capabilities.
-
#file_detector ⇒ Object
Returns the value of attribute file_detector.
-
#http ⇒ Object
Returns the value of attribute http.
Class Method Summary collapse
Instance Method Summary collapse
-
#accept_alert ⇒ Object
alerts.
-
#action(async: false, devices: [], duration: 250) ⇒ Object
(also: #actions)
actions.
-
#active_element ⇒ Object
(also: #switch_to_active_element)
finding elements.
- #add_cookie(cookie) ⇒ Object
- #add_credential(credential, id) ⇒ Object
-
#add_virtual_authenticator(options) ⇒ Object
virtual-authenticator.
- #alert=(keys) ⇒ Object
- #alert_text ⇒ Object
- #bidi ⇒ Object
- #browser ⇒ Object
-
#cancel_fedcm_dialog ⇒ Object
federated-credential management.
- #clear_element(element) ⇒ Object
- #click_element(element) ⇒ Object
- #click_fedcm_dialog_button ⇒ Object
- #close ⇒ Object
- #command_list ⇒ Object
- #cookie(name) ⇒ Object
- #cookies ⇒ Object
-
#create_session(capabilities) ⇒ Object
Creates session.
- #credentials(authenticator_id) ⇒ Object
- #delete_all_cookies ⇒ Object
- #delete_cookie(name) ⇒ Object
- #dismiss_alert ⇒ Object
- #element_aria_label(element) ⇒ Object
- #element_aria_role(element) ⇒ Object
- #element_attribute(element, name) ⇒ Object
- #element_displayed?(element) ⇒ Boolean
- #element_dom_attribute(element, name) ⇒ Object
- #element_enabled?(element) ⇒ Boolean
- #element_location(element) ⇒ Object
- #element_location_once_scrolled_into_view(element) ⇒ Object
- #element_property(element, name) ⇒ Object
- #element_rect(element) ⇒ Object
- #element_screenshot(element) ⇒ Object
- #element_selected?(element) ⇒ Boolean
- #element_size(element) ⇒ Object
-
#element_tag_name(element) ⇒ Object
element properties.
- #element_text(element) ⇒ Object
- #element_value(element) ⇒ Object
- #element_value_of_css_property(element, prop) ⇒ Object
- #execute_async_script(script, *args) ⇒ Object
-
#execute_script(script, *args) ⇒ Object
javascript execution.
- #fedcm_account_list ⇒ Object
- #fedcm_delay(enabled) ⇒ Object
- #fedcm_dialog_type ⇒ Object
- #fedcm_subtitle ⇒ Object
- #fedcm_title ⇒ Object
- #find_element_by(how, what, parent_ref = []) ⇒ Object
- #find_elements_by(how, what, parent_ref = []) ⇒ Object
- #full_screen_window ⇒ Object
- #get(url) ⇒ Object
-
#go_back ⇒ Object
navigation.
- #go_forward ⇒ Object
-
#initialize(url:, http_client: nil) ⇒ Bridge
constructor
private
Initializes the bridge with the given server URL.
-
#manage ⇒ Object
cookies.
- #maximize_window(handle = :current) ⇒ Object
- #minimize_window ⇒ Object
-
#new_window(type) ⇒ Hash
Create a new top-level browsing context w3c.github.io/webdriver/#new-window.
- #page_source ⇒ Object
- #print_page(options = {}) ⇒ Object
- #quit ⇒ Object
- #refresh ⇒ Object
- #release_actions ⇒ Object
- #remove_all_credentials(authenticator_id) ⇒ Object
- #remove_credential(credential_id, authenticator_id) ⇒ Object
- #remove_virtual_authenticator(id) ⇒ Object
- #reposition_window(x, y) ⇒ Object
- #reset_fedcm_cooldown ⇒ Object
- #resize_window(width, height, handle = :current) ⇒ Object
- #screenshot ⇒ Object
- #select_fedcm_account(index) ⇒ Object
- #send_actions(data) ⇒ Object
- #send_keys_to_element(element, keys) ⇒ Object
-
#session_id ⇒ Object
Returns the current session ID.
- #set_window_rect(x: nil, y: nil, width: nil, height: nil) ⇒ Object
- #shadow_root(element) ⇒ Object
- #status ⇒ Object
- #submit_element(element) ⇒ Object
- #switch_to_default_content ⇒ Object
- #switch_to_frame(id) ⇒ Object
- #switch_to_parent_frame ⇒ Object
- #switch_to_window(name) ⇒ Object
-
#timeouts ⇒ Object
timeouts.
- #timeouts=(timeouts) ⇒ Object
- #title ⇒ Object
- #url ⇒ Object
- #user_verified(verified, authenticator_id) ⇒ Object
- #window_handle ⇒ Object
-
#window_handles ⇒ Object
window handling.
- #window_position ⇒ Object
- #window_rect ⇒ Object
- #window_size(handle = :current) ⇒ Object
Methods included from Atoms
Constructor Details
#initialize(url:, http_client: nil) ⇒ Bridge
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the bridge with the given server URL
60 61 62 63 64 65 66 67 68 69 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 60 def initialize(url:, http_client: nil) uri = url.is_a?(URI) ? url : URI.parse(url) uri.path += '/' unless uri.path.end_with?('/') @http = http_client || Http::Default.new @http.server_url = uri @file_detector = nil @locator_converter = self.class.locator_converter end |
Class Attribute Details
.element_class ⇒ Object
48 49 50 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 48 def element_class @element_class ||= Element end |
.extra_commands ⇒ Object (readonly)
Returns the value of attribute extra_commands.
35 36 37 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 35 def extra_commands @extra_commands end |
.locator_converter ⇒ Object
44 45 46 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 44 def locator_converter @locator_converter ||= LocatorConverter.new end |
Instance Attribute Details
#capabilities ⇒ Object (readonly)
Returns the value of attribute capabilities.
32 33 34 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 32 def capabilities @capabilities end |
#file_detector ⇒ Object
Returns the value of attribute file_detector.
31 32 33 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 31 def file_detector @file_detector end |
#http ⇒ Object
Returns the value of attribute http.
31 32 33 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 31 def http @http end |
Class Method Details
.add_command(name, verb, url, &block) ⇒ Object
38 39 40 41 42 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 38 def add_command(name, verb, url, &block) @extra_commands ||= {} @extra_commands[name] = [verb, url] define_method(name, &block) end |
Instance Method Details
#accept_alert ⇒ Object
alerts
138 139 140 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 138 def accept_alert execute :accept_alert end |
#action(async: false, devices: [], duration: 250) ⇒ Object Also known as: actions
actions
347 348 349 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 347 def action(async: false, devices: [], duration: 250) ActionBuilder.new self, async: async, devices: devices, duration: duration end |
#active_element ⇒ Object Also known as: switch_to_active_element
finding elements
475 476 477 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 475 def active_element Bridge.element_class.new self, element_id_from(execute(:get_active_element)) end |
#add_cookie(cookie) ⇒ Object
321 322 323 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 321 def () execute :add_cookie, {}, {cookie: } end |
#add_credential(credential, id) ⇒ Object
535 536 537 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 535 def add_credential(credential, id) execute :add_credential, {authenticatorId: id}, credential end |
#add_virtual_authenticator(options) ⇒ Object
virtual-authenticator
526 527 528 529 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 526 def add_virtual_authenticator() authenticator_id = execute :add_virtual_authenticator, {}, .as_json VirtualAuthenticator.new(self, authenticator_id, ) end |
#alert=(keys) ⇒ Object
146 147 148 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 146 def alert=(keys) execute :send_alert_text, {}, {value: keys.chars, text: keys} end |
#alert_text ⇒ Object
150 151 152 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 150 def alert_text execute :get_alert_text end |
#bidi ⇒ Object
595 596 597 598 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 595 def bidi msg = 'BiDi must be enabled by setting #web_socket_url to true in options class' raise(WebDriver::Error::WebDriverError, msg) end |
#browser ⇒ Object
107 108 109 110 111 112 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 107 def browser @browser ||= begin name = @capabilities.browser_name name ? name.tr(' -', '_').downcase.to_sym : 'unknown' end end |
#cancel_fedcm_dialog ⇒ Object
federated-credential management
559 560 561 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 559 def cancel_fedcm_dialog execute :cancel_fedcm_dialog end |
#clear_element(element) ⇒ Object
374 375 376 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 374 def clear_element(element) execute :element_clear, id: element end |
#click_element(element) ⇒ Object
364 365 366 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 364 def click_element(element) execute :element_click, id: element end |
#click_fedcm_dialog_button ⇒ Object
591 592 593 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 591 def execute :click_fedcm_dialog_button, {}, {dialogButton: 'ConfirmIdpLoginContinue'} end |
#close ⇒ Object
218 219 220 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 218 def close execute :close_window end |
#command_list ⇒ Object
600 601 602 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 600 def command_list COMMANDS end |
#cookie(name) ⇒ Object
331 332 333 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 331 def (name) execute :get_cookie, name: name end |
#cookies ⇒ Object
335 336 337 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 335 def execute :get_all_cookies end |
#create_session(capabilities) ⇒ Object
Creates session.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 75 def create_session(capabilities) response = execute(:new_session, {}, prepare_capabilities_payload(capabilities)) @session_id = response['sessionId'] capabilities = response['capabilities'] raise Error::WebDriverError, 'no sessionId in returned payload' unless @session_id @capabilities = Capabilities.json_create(capabilities) case @capabilities[:browser_name] when 'chrome', 'chrome-headless-shell' extend(WebDriver::Chrome::Features) when 'firefox' extend(WebDriver::Firefox::Features) when 'msedge', 'MicrosoftEdge' extend(WebDriver::Edge::Features) when 'Safari', 'Safari Technology Preview' extend(WebDriver::Safari::Features) when 'internet explorer' extend(WebDriver::IE::Features) end end |
#credentials(authenticator_id) ⇒ Object
539 540 541 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 539 def credentials(authenticator_id) execute :get_credentials, {authenticatorId: authenticator_id} end |
#delete_all_cookies ⇒ Object
339 340 341 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 339 def execute :delete_all_cookies end |
#delete_cookie(name) ⇒ Object
325 326 327 328 329 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 325 def (name) raise ArgumentError, 'Cookie name cannot be null or empty' if name.nil? || name.strip.empty? execute :delete_cookie, name: name end |
#dismiss_alert ⇒ Object
142 143 144 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 142 def dismiss_alert execute :dismiss_alert end |
#element_aria_label(element) ⇒ Object
419 420 421 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 419 def element_aria_label(element) execute :get_element_aria_label, id: element end |
#element_aria_role(element) ⇒ Object
415 416 417 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 415 def element_aria_role(element) execute :get_element_aria_role, id: element end |
#element_attribute(element, name) ⇒ Object
402 403 404 405 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 402 def element_attribute(element, name) WebDriver.logger.debug "Using script for :getAttribute of #{name}", id: :script execute_atom :getAttribute, element, name end |
#element_displayed?(element) ⇒ Boolean
462 463 464 465 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 462 def element_displayed?(element) WebDriver.logger.debug 'Using script for :isDisplayed', id: :script execute_atom :isDisplayed, element end |
#element_dom_attribute(element, name) ⇒ Object
407 408 409 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 407 def element_dom_attribute(element, name) execute :get_element_attribute, id: element, name: name end |
#element_enabled?(element) ⇒ Boolean
454 455 456 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 454 def element_enabled?(element) execute :is_element_enabled, id: element end |
#element_location(element) ⇒ Object
431 432 433 434 435 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 431 def element_location(element) data = execute :get_element_rect, id: element Point.new data['x'], data['y'] end |
#element_location_once_scrolled_into_view(element) ⇒ Object
443 444 445 446 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 443 def element_location_once_scrolled_into_view(element) send_keys_to_element(element, ['']) element_location(element) end |
#element_property(element, name) ⇒ Object
411 412 413 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 411 def element_property(element, name) execute :get_element_property, id: element, name: name end |
#element_rect(element) ⇒ Object
437 438 439 440 441 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 437 def element_rect(element) data = execute :get_element_rect, id: element Rectangle.new data['x'], data['y'], data['width'], data['height'] end |
#element_screenshot(element) ⇒ Object
295 296 297 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 295 def element_screenshot(element) execute :take_element_screenshot, id: element end |
#element_selected?(element) ⇒ Boolean
458 459 460 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 458 def element_selected?(element) execute :is_element_selected, id: element end |
#element_size(element) ⇒ Object
448 449 450 451 452 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 448 def element_size(element) data = execute :get_element_rect, id: element Dimension.new data['width'], data['height'] end |
#element_tag_name(element) ⇒ Object
element properties
398 399 400 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 398 def element_tag_name(element) execute :get_element_tag_name, id: element end |
#element_text(element) ⇒ Object
427 428 429 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 427 def element_text(element) execute :get_element_text, id: element end |
#element_value(element) ⇒ Object
423 424 425 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 423 def element_value(element) element_property element, 'value' end |
#element_value_of_css_property(element, prop) ⇒ Object
467 468 469 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 467 def element_value_of_css_property(element, prop) execute :get_element_css_value, id: element, property_name: prop end |
#execute_async_script(script, *args) ⇒ Object
308 309 310 311 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 308 def execute_async_script(script, *args) result = execute :execute_async_script, {}, {script: script, args: args} unwrap_script_result result end |
#execute_script(script, *args) ⇒ Object
javascript execution
303 304 305 306 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 303 def execute_script(script, *args) result = execute :execute_script, {}, {script: script, args: args} unwrap_script_result result end |
#fedcm_account_list ⇒ Object
579 580 581 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 579 def fedcm_account_list execute :get_fedcm_account_list end |
#fedcm_delay(enabled) ⇒ Object
583 584 585 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 583 def fedcm_delay(enabled) execute :set_fedcm_delay, {}, {enabled: enabled} end |
#fedcm_dialog_type ⇒ Object
567 568 569 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 567 def fedcm_dialog_type execute :get_fedcm_dialog_type end |
#fedcm_subtitle ⇒ Object
575 576 577 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 575 def fedcm_subtitle execute(:get_fedcm_title).fetch('subtitle', nil) end |
#fedcm_title ⇒ Object
571 572 573 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 571 def fedcm_title execute(:get_fedcm_title).fetch('title') end |
#find_element_by(how, what, parent_ref = []) ⇒ Object
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 481 def find_element_by(how, what, parent_ref = []) how, what = @locator_converter.convert(how, what) return execute_atom(:findElements, Support::RelativeLocator.new(what).as_json).first if how == 'relative' parent_type, parent_id = parent_ref id = case parent_type when :element execute :find_child_element, {id: parent_id}, {using: how, value: what.to_s} when :shadow_root execute :find_shadow_child_element, {id: parent_id}, {using: how, value: what.to_s} else execute :find_element, {}, {using: how, value: what.to_s} end Bridge.element_class.new self, element_id_from(id) end |
#find_elements_by(how, what, parent_ref = []) ⇒ Object
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 499 def find_elements_by(how, what, parent_ref = []) how, what = @locator_converter.convert(how, what) return execute_atom :findElements, Support::RelativeLocator.new(what).as_json if how == 'relative' parent_type, parent_id = parent_ref ids = case parent_type when :element execute :find_child_elements, {id: parent_id}, {using: how, value: what.to_s} when :shadow_root execute :find_shadow_child_elements, {id: parent_id}, {using: how, value: what.to_s} else execute :find_elements, {}, {using: how, value: what.to_s} end ids.map { |id| Bridge.element_class.new self, element_id_from(id) } end |
#full_screen_window ⇒ Object
267 268 269 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 267 def full_screen_window execute :fullscreen_window end |
#get(url) ⇒ Object
118 119 120 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 118 def get(url) execute :get, {}, {url: url} end |
#go_back ⇒ Object
navigation
158 159 160 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 158 def go_back execute :back end |
#go_forward ⇒ Object
162 163 164 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 162 def go_forward execute :forward end |
#manage ⇒ Object
cookies
317 318 319 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 317 def manage @manage ||= WebDriver::Manager.new(self) end |
#maximize_window(handle = :current) ⇒ Object
258 259 260 261 262 263 264 265 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 258 def maximize_window(handle = :current) unless handle == :current raise Error::UnsupportedOperationError, 'Switch to desired window before changing its size' end execute :maximize_window end |
#minimize_window ⇒ Object
254 255 256 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 254 def minimize_window execute :minimize_window end |
#new_window(type) ⇒ Hash
Create a new top-level browsing context w3c.github.io/webdriver/#new-window
188 189 190 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 188 def new_window(type) execute :new_window, {}, {type: type} end |
#page_source ⇒ Object
174 175 176 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 174 def page_source execute :get_page_source end |
#print_page(options = {}) ⇒ Object
360 361 362 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 360 def print_page( = {}) execute :print_page, {}, {options: } end |
#quit ⇒ Object
211 212 213 214 215 216 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 211 def quit execute :delete_session http.close rescue *QUIT_ERRORS nil end |
#refresh ⇒ Object
222 223 224 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 222 def refresh execute :refresh end |
#release_actions ⇒ Object
356 357 358 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 356 def release_actions execute :release_actions end |
#remove_all_credentials(authenticator_id) ⇒ Object
547 548 549 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 547 def remove_all_credentials(authenticator_id) execute :remove_all_credentials, {authenticatorId: authenticator_id} end |
#remove_credential(credential_id, authenticator_id) ⇒ Object
543 544 545 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 543 def remove_credential(credential_id, authenticator_id) execute :remove_credential, {credentialId: credential_id, authenticatorId: authenticator_id} end |
#remove_virtual_authenticator(id) ⇒ Object
531 532 533 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 531 def remove_virtual_authenticator(id) execute :remove_virtual_authenticator, {authenticatorId: id} end |
#reposition_window(x, y) ⇒ Object
271 272 273 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 271 def reposition_window(x, y) set_window_rect(x: x, y: y) end |
#reset_fedcm_cooldown ⇒ Object
587 588 589 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 587 def reset_fedcm_cooldown execute :reset_fedcm_cooldown end |
#resize_window(width, height, handle = :current) ⇒ Object
238 239 240 241 242 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 238 def resize_window(width, height, handle = :current) raise Error::WebDriverError, 'Switch to desired window before changing its size' unless handle == :current set_window_rect(width: width, height: height) end |
#screenshot ⇒ Object
291 292 293 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 291 def screenshot execute :take_screenshot end |
#select_fedcm_account(index) ⇒ Object
563 564 565 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 563 def select_fedcm_account(index) execute :select_fedcm_account, {}, {accountIndex: index} end |
#send_actions(data) ⇒ Object
352 353 354 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 352 def send_actions(data) execute :actions, {}, {actions: data} end |
#send_keys_to_element(element, keys) ⇒ Object
368 369 370 371 372 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 368 def send_keys_to_element(element, keys) keys = upload_if_necessary(keys) if @file_detector text = keys.join execute :element_send_keys, {id: element}, {value: text.chars, text: text} end |
#session_id ⇒ Object
Returns the current session ID.
103 104 105 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 103 def session_id @session_id || raise(Error::WebDriverError, 'no current session exists') end |
#set_window_rect(x: nil, y: nil, width: nil, height: nil) ⇒ Object
280 281 282 283 284 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 280 def set_window_rect(x: nil, y: nil, width: nil, height: nil) params = {x: x, y: y, width: width, height: height} params.update(params) { |_k, v| Integer(v) unless v.nil? } execute :set_window_rect, {}, params end |
#shadow_root(element) ⇒ Object
517 518 519 520 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 517 def shadow_root(element) id = execute :get_element_shadow_root, id: element ShadowRoot.new self, shadow_root_id_from(id) end |
#status ⇒ Object
114 115 116 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 114 def status execute :status end |
#submit_element(element) ⇒ Object
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 378 def submit_element(element) script = "/* submitForm */ var form = arguments[0];\n" \ "while (form.nodeName != \"FORM\" && form.parentNode) {\n " \ "form = form.parentNode;\n" \ "}\n" \ "if (!form) { throw Error('Unable to find containing form element'); }\n" \ "if (!form.ownerDocument) { throw Error('Unable to find owning document'); }\n" \ "var e = form.ownerDocument.createEvent('Event');\n" \ "e.initEvent('submit', true, true);\n" \ "if (form.dispatchEvent(e)) { HTMLFormElement.prototype.submit.call(form) }\n" execute_script(script, Bridge.element_class::ELEMENT_KEY => element) rescue Error::JavascriptError raise Error::UnsupportedOperationError, 'To submit an element, it must be nested inside a form element' end |
#switch_to_default_content ⇒ Object
205 206 207 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 205 def switch_to_default_content switch_to_frame nil end |
#switch_to_frame(id) ⇒ Object
196 197 198 199 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 196 def switch_to_frame(id) id = find_element_by('id', id) if id.is_a? String execute :switch_to_frame, {}, {id: id} end |
#switch_to_parent_frame ⇒ Object
201 202 203 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 201 def switch_to_parent_frame execute :switch_to_parent_frame end |
#switch_to_window(name) ⇒ Object
192 193 194 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 192 def switch_to_window(name) execute :switch_to_window, {}, {handle: name} end |
#timeouts ⇒ Object
timeouts
126 127 128 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 126 def timeouts execute :get_timeouts, {} end |
#timeouts=(timeouts) ⇒ Object
130 131 132 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 130 def timeouts=(timeouts) execute :set_timeout, {}, timeouts end |
#title ⇒ Object
170 171 172 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 170 def title execute :get_title end |
#url ⇒ Object
166 167 168 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 166 def url execute :get_current_url end |
#user_verified(verified, authenticator_id) ⇒ Object
551 552 553 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 551 def user_verified(verified, authenticator_id) execute :set_user_verified, {authenticatorId: authenticator_id}, {isUserVerified: verified} end |
#window_handle ⇒ Object
234 235 236 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 234 def window_handle execute :get_window_handle end |
#window_handles ⇒ Object
window handling
230 231 232 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 230 def window_handles execute :get_window_handles end |
#window_position ⇒ Object
275 276 277 278 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 275 def window_position data = execute :get_window_rect Point.new data['x'], data['y'] end |
#window_rect ⇒ Object
286 287 288 289 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 286 def window_rect data = execute :get_window_rect Rectangle.new data['x'], data['y'], data['width'], data['height'] end |
#window_size(handle = :current) ⇒ Object
244 245 246 247 248 249 250 251 252 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 244 def window_size(handle = :current) unless handle == :current raise Error::UnsupportedOperationError, 'Switch to desired window before getting its size' end data = execute :get_window_rect Dimension.new data['width'], data['height'] end |