Class: Selenium::WebDriver::Remote::Bridge Private
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Remote::Bridge
- Includes:
- Atoms
- Defined in:
- rb/lib/selenium/webdriver/remote/bridge.rb,
rb/lib/selenium/webdriver/remote/bridge/commands.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 =
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.
4444- QUIT_ERRORS =
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.
[IOError, EOFError, WebSocket::Error].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 private
- .extra_commands ⇒ Object readonly private
- .locator_converter ⇒ Object private
Instance Attribute Summary collapse
- #capabilities ⇒ Object readonly private
- #file_detector ⇒ Object private
- #http ⇒ Object private
Class Method Summary collapse
Instance Method Summary collapse
-
#accept_alert ⇒ Object
private
alerts.
-
#action(async: false, devices: [], duration: 250) ⇒ Object
(also: #actions)
private
actions.
-
#active_element ⇒ Object
(also: #switch_to_active_element)
private
finding elements.
- #add_cookie(cookie) ⇒ Object private
- #add_credential(credential, id) ⇒ Object private
-
#add_virtual_authenticator(options) ⇒ Object
private
virtual-authenticator.
- #alert=(keys) ⇒ Object private
- #alert_text ⇒ Object private
- #bidi ⇒ Object (also: #connection, #web_extension, #install_web_extension, #uninstall_web_extension) private
- #bidi? ⇒ Boolean private
- #browser ⇒ Object private
-
#cancel_fedcm_dialog ⇒ Object
private
federated-credential management.
- #clear_element(element) ⇒ Object private
- #click_element(element) ⇒ Object private
- #click_fedcm_dialog_button ⇒ Object private
- #close ⇒ Object private
- #command_list ⇒ Object private
- #cookie(name) ⇒ Object private
- #cookies ⇒ Object private
-
#create_session(capabilities) ⇒ Object
private
Creates session.
- #credentials(authenticator_id) ⇒ Object private
- #delete_all_cookies ⇒ Object private
- #delete_cookie(name) ⇒ Object private
- #dismiss_alert ⇒ Object private
- #element_aria_label(element) ⇒ Object private
- #element_aria_role(element) ⇒ Object private
- #element_attribute(element, name) ⇒ Object private
- #element_displayed?(element) ⇒ Boolean private
- #element_dom_attribute(element, name) ⇒ Object private
- #element_enabled?(element) ⇒ Boolean private
- #element_location(element) ⇒ Object private
- #element_location_once_scrolled_into_view(element) ⇒ Object private
- #element_property(element, name) ⇒ Object private
- #element_rect(element) ⇒ Object private
- #element_screenshot(element) ⇒ Object private
- #element_selected?(element) ⇒ Boolean private
- #element_size(element) ⇒ Object private
-
#element_tag_name(element) ⇒ Object
private
element properties.
- #element_text(element) ⇒ Object private
- #element_value(element) ⇒ Object private
- #element_value_of_css_property(element, prop) ⇒ Object private
- #execute_async_script(script, *args) ⇒ Object private
-
#execute_script(script, *args) ⇒ Object
private
javascript execution.
- #fedcm_account_list ⇒ Object private
- #fedcm_delay(enabled) ⇒ Object private
- #fedcm_dialog_type ⇒ Object private
- #fedcm_subtitle ⇒ Object private
- #fedcm_title ⇒ Object private
- #find_element_by(how, what, parent_ref = []) ⇒ Object private
- #find_elements_by(how, what, parent_ref = []) ⇒ Object private
- #full_screen_window ⇒ Object private
- #get(url) ⇒ Object private
-
#go_back ⇒ Object
private
navigation.
- #go_forward ⇒ Object private
-
#initialize(http_client:) ⇒ Bridge
constructor
private
A new instance of Bridge.
-
#manage ⇒ Object
private
cookies.
- #maximize_window(handle = :current) ⇒ Object private
- #minimize_window ⇒ Object private
-
#new_window(type) ⇒ Hash
private
Create a new top-level browsing context https://w3c.github.io/webdriver/#new-window.
- #page_source ⇒ Object private
- #print_page(options = {}) ⇒ Object private
- #quit ⇒ Object private
- #refresh ⇒ Object private
- #release_actions ⇒ Object private
- #remove_all_credentials(authenticator_id) ⇒ Object private
- #remove_credential(credential_id, authenticator_id) ⇒ Object private
- #remove_virtual_authenticator(id) ⇒ Object private
- #reposition_window(x, y) ⇒ Object private
- #reset_fedcm_cooldown ⇒ Object private
- #resize_window(width, height, handle = :current) ⇒ Object private
- #screenshot ⇒ Object private
- #select_fedcm_account(index) ⇒ Object private
- #send_actions(data) ⇒ Object private
- #send_keys_to_element(element, keys) ⇒ Object private
-
#session_id ⇒ Object
private
Returns the current session ID.
- #set_window_rect(x: nil, y: nil, width: nil, height: nil) ⇒ Object private
- #shadow_root(element) ⇒ Object private
- #status ⇒ Object private
- #submit_element(element) ⇒ Object private
- #switch_to_default_content ⇒ Object private
- #switch_to_frame(id) ⇒ Object private
- #switch_to_parent_frame ⇒ Object private
- #switch_to_window(name) ⇒ Object private
-
#timeouts ⇒ Object
private
timeouts.
- #timeouts=(timeouts) ⇒ Object private
- #title ⇒ Object private
- #url ⇒ Object private
- #user_verified(verified, authenticator_id) ⇒ Object private
- #window_handle ⇒ Object private
-
#window_handles ⇒ Object
private
window handling.
- #window_position ⇒ Object private
- #window_rect ⇒ Object private
- #window_size(handle = :current) ⇒ Object private
Methods included from Atoms
Constructor Details
#initialize(http_client:) ⇒ 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.
Returns a new instance of Bridge.
59 60 61 62 63 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 59 def initialize(http_client:) @http = http_client @file_detector = nil @locator_converter = self.class.locator_converter end |
Class Attribute Details
.element_class ⇒ Object
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.
49 50 51 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 49 def element_class @element_class ||= Element end |
.extra_commands ⇒ Object (readonly)
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.
36 37 38 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 36 def extra_commands @extra_commands end |
.locator_converter ⇒ Object
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.
45 46 47 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 45 def locator_converter @locator_converter ||= LocatorConverter.new end |
Instance Attribute Details
#capabilities ⇒ Object (readonly)
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.
33 34 35 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 33 def capabilities @capabilities end |
#file_detector ⇒ Object
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.
32 33 34 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 32 def file_detector @file_detector end |
#http ⇒ Object
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.
32 33 34 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 32 def http @http end |
Class Method Details
.add_command(name, verb, url, &block) ⇒ Object
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.
39 40 41 42 43 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 39 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
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.
alerts
132 133 134 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 132 def accept_alert execute :accept_alert end |
#action(async: false, devices: [], duration: 250) ⇒ Object Also known as: actions
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.
actions
349 350 351 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 349 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
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.
finding elements
477 478 479 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 477 def active_element Bridge.element_class.new self, element_id_from(execute(:get_active_element)) end |
#add_cookie(cookie) ⇒ Object
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.
323 324 325 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 323 def () execute :add_cookie, {}, {cookie: } end |
#add_credential(credential, id) ⇒ Object
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.
537 538 539 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 537 def add_credential(credential, id) execute :add_credential, {authenticatorId: id}, credential end |
#add_virtual_authenticator(options) ⇒ Object
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.
virtual-authenticator
528 529 530 531 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 528 def add_virtual_authenticator() authenticator_id = execute :add_virtual_authenticator, {}, .as_json VirtualAuthenticator.new(self, authenticator_id, ) end |
#alert=(keys) ⇒ Object
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.
140 141 142 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 140 def alert=(keys) execute :send_alert_text, {}, {value: keys.chars, text: keys} end |
#alert_text ⇒ Object
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.
144 145 146 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 144 def alert_text execute :get_alert_text end |
#bidi ⇒ Object Also known as: connection, web_extension, install_web_extension, uninstall_web_extension
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.
597 598 599 600 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 597 def bidi(*) raise WebDriver::Error::WebDriverError, 'BiDi must be enabled by setting #web_socket_url to true in options class' end |
#bidi? ⇒ Boolean
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.
607 608 609 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 607 def bidi? !@bidi.nil? end |
#browser ⇒ Object
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.
101 102 103 104 105 106 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 101 def browser @browser ||= begin name = @capabilities.browser_name name ? name.tr(' -', '_').downcase.to_sym : 'unknown' end end |
#cancel_fedcm_dialog ⇒ Object
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.
federated-credential management
561 562 563 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 561 def cancel_fedcm_dialog execute :cancel_fedcm_dialog end |
#clear_element(element) ⇒ Object
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.
376 377 378 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 376 def clear_element(element) execute :element_clear, id: element end |
#click_element(element) ⇒ Object
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.
366 367 368 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 366 def click_element(element) execute :element_click, id: element end |
#click_fedcm_dialog_button ⇒ Object
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.
593 594 595 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 593 def execute :click_fedcm_dialog_button, {}, {dialogButton: 'ConfirmIdpLoginContinue'} end |
#close ⇒ Object
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.
220 221 222 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 220 def close execute :close_window end |
#command_list ⇒ Object
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.
611 612 613 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 611 def command_list COMMANDS end |
#cookie(name) ⇒ Object
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.
333 334 335 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 333 def (name) execute :get_cookie, name: name end |
#cookies ⇒ Object
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.
337 338 339 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 337 def execute :get_all_cookies end |
#create_session(capabilities) ⇒ Object
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.
Creates session.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 69 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
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.
541 542 543 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 541 def credentials(authenticator_id) execute :get_credentials, {authenticatorId: authenticator_id} end |
#delete_all_cookies ⇒ Object
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.
341 342 343 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 341 def execute :delete_all_cookies end |
#delete_cookie(name) ⇒ Object
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.
327 328 329 330 331 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 327 def (name) raise ArgumentError, 'Cookie name cannot be null or empty' if name.nil? || name.to_s.strip.empty? execute :delete_cookie, name: name end |
#dismiss_alert ⇒ Object
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.
136 137 138 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 136 def dismiss_alert execute :dismiss_alert end |
#element_aria_label(element) ⇒ Object
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.
421 422 423 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 421 def element_aria_label(element) execute :get_element_aria_label, id: element end |
#element_aria_role(element) ⇒ Object
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.
417 418 419 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 417 def element_aria_role(element) execute :get_element_aria_role, id: element end |
#element_attribute(element, name) ⇒ Object
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.
404 405 406 407 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 404 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
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.
464 465 466 467 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 464 def element_displayed?(element) WebDriver.logger.debug 'Using script for :isDisplayed', id: :script execute_atom :isDisplayed, element end |
#element_dom_attribute(element, name) ⇒ Object
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.
409 410 411 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 409 def element_dom_attribute(element, name) execute :get_element_attribute, id: element, name: name end |
#element_enabled?(element) ⇒ Boolean
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.
456 457 458 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 456 def element_enabled?(element) execute :is_element_enabled, id: element end |
#element_location(element) ⇒ Object
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.
433 434 435 436 437 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 433 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
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.
445 446 447 448 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 445 def element_location_once_scrolled_into_view(element) send_keys_to_element(element, ['']) element_location(element) end |
#element_property(element, name) ⇒ Object
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.
413 414 415 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 413 def element_property(element, name) execute :get_element_property, id: element, name: name end |
#element_rect(element) ⇒ Object
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.
439 440 441 442 443 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 439 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
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.
297 298 299 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 297 def element_screenshot(element) execute :take_element_screenshot, id: element end |
#element_selected?(element) ⇒ Boolean
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.
460 461 462 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 460 def element_selected?(element) execute :is_element_selected, id: element end |
#element_size(element) ⇒ Object
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.
450 451 452 453 454 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 450 def element_size(element) data = execute :get_element_rect, id: element Dimension.new data['width'], data['height'] end |
#element_tag_name(element) ⇒ Object
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.
element properties
400 401 402 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 400 def element_tag_name(element) execute :get_element_tag_name, id: element end |
#element_text(element) ⇒ Object
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.
429 430 431 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 429 def element_text(element) execute :get_element_text, id: element end |
#element_value(element) ⇒ Object
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.
425 426 427 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 425 def element_value(element) element_property element, 'value' end |
#element_value_of_css_property(element, prop) ⇒ Object
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.
469 470 471 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 469 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
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.
310 311 312 313 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 310 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
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.
javascript execution
305 306 307 308 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 305 def execute_script(script, *args) result = execute :execute_script, {}, {script: script, args: args} unwrap_script_result result end |
#fedcm_account_list ⇒ Object
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.
581 582 583 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 581 def fedcm_account_list execute :get_fedcm_account_list end |
#fedcm_delay(enabled) ⇒ Object
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.
585 586 587 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 585 def fedcm_delay(enabled) execute :set_fedcm_delay, {}, {enabled: enabled} end |
#fedcm_dialog_type ⇒ Object
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.
569 570 571 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 569 def fedcm_dialog_type execute :get_fedcm_dialog_type end |
#fedcm_subtitle ⇒ Object
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.
577 578 579 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 577 def fedcm_subtitle execute(:get_fedcm_title).fetch('subtitle', nil) end |
#fedcm_title ⇒ Object
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.
573 574 575 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 573 def fedcm_title execute(:get_fedcm_title).fetch('title') end |
#find_element_by(how, what, parent_ref = []) ⇒ Object
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.
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 483 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
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.
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 501 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
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.
269 270 271 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 269 def full_screen_window execute :fullscreen_window end |
#get(url) ⇒ Object
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.
112 113 114 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 112 def get(url) execute :get, {}, {url: url} end |
#go_back ⇒ Object
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.
navigation
152 153 154 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 152 def go_back execute :back end |
#go_forward ⇒ Object
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.
156 157 158 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 156 def go_forward execute :forward end |
#manage ⇒ Object
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.
cookies
319 320 321 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 319 def manage @manage ||= WebDriver::Manager.new(self) end |
#maximize_window(handle = :current) ⇒ Object
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.
260 261 262 263 264 265 266 267 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 260 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
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.
256 257 258 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 256 def minimize_window execute :minimize_window end |
#new_window(type) ⇒ Hash
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.
Create a new top-level browsing context https://w3c.github.io/webdriver/#new-window
182 183 184 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 182 def new_window(type) execute :new_window, {}, {type: type} end |
#page_source ⇒ Object
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.
168 169 170 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 168 def page_source execute :get_page_source end |
#print_page(options = {}) ⇒ Object
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.
362 363 364 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 362 def print_page( = {}) execute :print_page, {}, {options: } end |
#quit ⇒ Object
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.
205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 205 def quit begin execute :delete_session rescue *QUIT_ERRORS => e WebDriver.logger.debug "delete_session failed during quit: #{e.class}: #{e.}", id: :quit ensure begin http.close rescue *QUIT_ERRORS => e WebDriver.logger.debug "http.close failed during quit: #{e.class}: #{e.}", id: :quit end end nil end |
#refresh ⇒ Object
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.
224 225 226 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 224 def refresh execute :refresh end |
#release_actions ⇒ Object
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.
358 359 360 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 358 def release_actions execute :release_actions end |
#remove_all_credentials(authenticator_id) ⇒ Object
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.
549 550 551 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 549 def remove_all_credentials(authenticator_id) execute :remove_all_credentials, {authenticatorId: authenticator_id} end |
#remove_credential(credential_id, authenticator_id) ⇒ Object
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.
545 546 547 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 545 def remove_credential(credential_id, authenticator_id) execute :remove_credential, {credentialId: credential_id, authenticatorId: authenticator_id} end |
#remove_virtual_authenticator(id) ⇒ Object
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.
533 534 535 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 533 def remove_virtual_authenticator(id) execute :remove_virtual_authenticator, {authenticatorId: id} end |
#reposition_window(x, y) ⇒ Object
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.
273 274 275 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 273 def reposition_window(x, y) set_window_rect(x: x, y: y) end |
#reset_fedcm_cooldown ⇒ Object
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.
589 590 591 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 589 def reset_fedcm_cooldown execute :reset_fedcm_cooldown end |
#resize_window(width, height, handle = :current) ⇒ Object
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.
240 241 242 243 244 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 240 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
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.
293 294 295 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 293 def screenshot execute :take_screenshot end |
#select_fedcm_account(index) ⇒ Object
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.
565 566 567 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 565 def select_fedcm_account(index) execute :select_fedcm_account, {}, {accountIndex: index} end |
#send_actions(data) ⇒ Object
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.
354 355 356 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 354 def send_actions(data) execute :actions, {}, {actions: data} end |
#send_keys_to_element(element, keys) ⇒ Object
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.
370 371 372 373 374 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 370 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
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.
Returns the current session ID.
97 98 99 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 97 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
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.
282 283 284 285 286 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 282 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
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.
519 520 521 522 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 519 def shadow_root(element) id = execute :get_element_shadow_root, id: element ShadowRoot.new self, shadow_root_id_from(id) end |
#status ⇒ Object
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.
108 109 110 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 108 def status execute :status end |
#submit_element(element) ⇒ Object
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.
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 380 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
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.
199 200 201 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 199 def switch_to_default_content switch_to_frame nil end |
#switch_to_frame(id) ⇒ Object
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.
190 191 192 193 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 190 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
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.
195 196 197 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 195 def switch_to_parent_frame execute :switch_to_parent_frame end |
#switch_to_window(name) ⇒ Object
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.
186 187 188 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 186 def switch_to_window(name) execute :switch_to_window, {}, {handle: name} end |
#timeouts ⇒ Object
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.
timeouts
120 121 122 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 120 def timeouts execute :get_timeouts, {} end |
#timeouts=(timeouts) ⇒ Object
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.
124 125 126 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 124 def timeouts=(timeouts) execute :set_timeout, {}, timeouts end |
#title ⇒ Object
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.
164 165 166 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 164 def title execute :get_title end |
#url ⇒ Object
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.
160 161 162 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 160 def url execute :get_current_url end |
#user_verified(verified, authenticator_id) ⇒ Object
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.
553 554 555 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 553 def user_verified(verified, authenticator_id) execute :set_user_verified, {authenticatorId: authenticator_id}, {isUserVerified: verified} end |
#window_handle ⇒ Object
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.
236 237 238 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 236 def window_handle execute :get_window_handle end |
#window_handles ⇒ Object
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.
window handling
232 233 234 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 232 def window_handles execute :get_window_handles end |
#window_position ⇒ Object
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.
277 278 279 280 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 277 def window_position data = execute :get_window_rect Point.new data['x'], data['y'] end |
#window_rect ⇒ Object
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.
288 289 290 291 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 288 def window_rect data = execute :get_window_rect Rectangle.new data['x'], data['y'], data['width'], data['height'] end |
#window_size(handle = :current) ⇒ Object
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.
246 247 248 249 250 251 252 253 254 |
# File 'rb/lib/selenium/webdriver/remote/bridge.rb', line 246 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 |