Class: Selenium::WebDriver::Edge::Bridge Private
- Inherits:
-
Remote::W3CBridge
- Object
- Remote::W3CBridge
- Selenium::WebDriver::Edge::Bridge
- Defined in:
- lib/selenium/webdriver/edge/bridge.rb
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.
Constant Summary
Constants inherited from Remote::W3CBridge
Remote::W3CBridge::COMMANDS, Remote::W3CBridge::QUIT_ERRORS
Instance Attribute Summary
Attributes inherited from Remote::W3CBridge
#context, #file_detector, #http
Instance Method Summary collapse
- #browser ⇒ Object private
- #capabilities ⇒ Object private
- #commands(command) ⇒ Object private
- #create_session(desired_capabilities) ⇒ Object private
- #driver_extensions ⇒ Object private
-
#execute(*args) ⇒ Object
private
executes a command on the remote server.
-
#initialize(opts = {}) ⇒ Bridge
constructor
private
A new instance of Bridge.
- #maximize_window(handle = :current) ⇒ Object private
- #quit ⇒ Object private
-
#raw_execute(command, opts = {}, command_hash = nil) ⇒ WebDriver::Remote::Response
private
executes a command on the remote server.
- #reposition_window(x, y, handle = :current) ⇒ Object private
- #resize_window(width, height, handle = :current) ⇒ Object private
- #send_keys_to_active_element(key) ⇒ Object private
- #window_handle ⇒ Object private
- #window_position(handle = :current) ⇒ Object private
- #window_size(handle = :current) ⇒ Object private
Methods inherited from Remote::W3CBridge
#accept_alert, #action, #active_element, #add_cookie, #alert=, #alert_text, #clear_element, #clear_local_storage, #clear_session_storage, #click_element, #close, #cookie, #cookies, #delete_all_cookies, #delete_cookie, #dismiss_alert, #drag_element, #element_attribute, #element_displayed?, #element_enabled?, #element_location, #element_location_once_scrolled_into_view, #element_property, #element_rect, #element_selected?, #element_size, #element_tag_name, #element_text, #element_value, #element_value_of_css_property, #execute_async_script, #execute_script, #find_element_by, #find_elements_by, #full_screen_window, #get, #go_back, #go_forward, #implicit_wait_timeout=, #keyboard, #local_storage_item, #local_storage_keys, #local_storage_size, #location, #minimize_window, #mouse, #network_connection, #network_connection=, #options, #page_source, #refresh, #release_actions, #remove_local_storage_item, #remove_session_storage_item, #screen_orientation, #screen_orientation=, #screenshot, #script_timeout=, #send_actions, #send_keys_to_element, #session_id, #session_storage_item, #session_storage_keys, #session_storage_size, #set_location, #set_window_rect, #status, #submit_element, #switch_to_default_content, #switch_to_frame, #switch_to_parent_frame, #switch_to_window, #timeout, #title, #touch_double_tap, #touch_down, #touch_element_flick, #touch_flick, #touch_long_press, #touch_move, #touch_scroll, #touch_single_tap, #touch_up, #url, #window_handles, #window_rect
Methods included from BridgeHelper
#element_id_from, #parse_cookie_string, #unwrap_script_result
Constructor Details
#initialize(opts = {}) ⇒ 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.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/selenium/webdriver/edge/bridge.rb', line 28 def initialize(opts = {}) opts[:desired_capabilities] ||= Remote::W3CCapabilities.edge unless opts.key?(:url) driver_path = opts.delete(:driver_path) || Edge.driver_path port = opts.delete(:port) || Service::DEFAULT_PORT opts[:driver_opts] ||= {} if opts.key? :service_args WebDriver.logger.warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze [DEPRECATION] `:service_args` is deprecated. Pass switches using `driver_opts` DEPRECATE opts[:driver_opts][:args] = opts.delete(:service_args) end @service = Service.new(driver_path, port, opts.delete(:driver_opts)) @service.host = 'localhost' if @service.host == '127.0.0.1' @service.start opts[:url] = @service.uri end super(opts) end |
Instance Method Details
#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.
52 53 54 |
# File 'lib/selenium/webdriver/edge/bridge.rb', line 52 def browser :edge end |
#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.
74 75 76 |
# File 'lib/selenium/webdriver/edge/bridge.rb', line 74 def capabilities @capabilities ||= Remote::Capabilities.edge end |
#commands(command) ⇒ 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.
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/selenium/webdriver/edge/bridge.rb', line 60 def commands(command) unsupported = %i[execute_script execute_async_script submit_element double_click mouse_down mouse_up mouse_move_to click send_keys_to_active_element get_window_handles get_current_window_handle get_window_size set_window_size get_window_position set_window_position maximize_window get_alert_text accept_alert dismiss_alert] if unsupported.include? command Remote::Bridge::COMMANDS[command] else super end end |
#create_session(desired_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.
119 120 121 122 123 124 125 |
# File 'lib/selenium/webdriver/edge/bridge.rb', line 119 def create_session(desired_capabilities) resp = raw_execute :new_session, {}, {desiredCapabilities: desired_capabilities} @session_id = resp['sessionId'] return Remote::W3CCapabilities.json_create resp['value'] if @session_id raise Error::WebDriverError, 'no sessionId in returned payload' end |
#driver_extensions ⇒ 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.
56 57 58 |
# File 'lib/selenium/webdriver/edge/bridge.rb', line 56 def driver_extensions [DriverExtensions::TakesScreenshot] end |
#execute(*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.
executes a command on the remote server.
Returns the ‘value’ of the returned payload
134 135 136 137 |
# File 'lib/selenium/webdriver/edge/bridge.rb', line 134 def execute(*args) result = raw_execute(*args) result.payload.key?('value') ? result['value'] : result 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.
115 116 117 |
# File 'lib/selenium/webdriver/edge/bridge.rb', line 115 def maximize_window(handle = :current) execute :maximize_window, window_handle: handle 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.
78 79 80 81 82 |
# File 'lib/selenium/webdriver/edge/bridge.rb', line 78 def quit super ensure @service.stop if @service end |
#raw_execute(command, opts = {}, command_hash = nil) ⇒ WebDriver::Remote::Response
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.
executes a command on the remote server.
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/selenium/webdriver/edge/bridge.rb', line 145 def raw_execute(command, opts = {}, command_hash = nil) verb, path = commands(command) || raise(ArgumentError, "unknown command: #{command.inspect}") path = path.dup path[':session_id'] = @session_id if path.include?(':session_id') begin opts.each do |key, value| path[key.inspect] = escaper.escape(value.to_s) end rescue IndexError raise ArgumentError, "#{opts.inspect} invalid for #{command.inspect}" end WebDriver.logger.info("-> #{verb.to_s.upcase} #{path}") http.call verb, path, command_hash end |
#reposition_window(x, y, 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.
110 111 112 113 |
# File 'lib/selenium/webdriver/edge/bridge.rb', line 110 def reposition_window(x, y, handle = :current) execute :set_window_position, {window_handle: handle}, {x: x, y: y} 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.
98 99 100 101 102 |
# File 'lib/selenium/webdriver/edge/bridge.rb', line 98 def resize_window(width, height, handle = :current) execute :set_window_size, {window_handle: handle}, {width: width, height: height} end |
#send_keys_to_active_element(key) ⇒ 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.
84 85 86 |
# File 'lib/selenium/webdriver/edge/bridge.rb', line 84 def send_keys_to_active_element(key) execute :send_keys_to_active_element, {}, {value: key} 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.
88 89 90 |
# File 'lib/selenium/webdriver/edge/bridge.rb', line 88 def window_handle execute :get_current_window_handle end |
#window_position(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.
104 105 106 107 108 |
# File 'lib/selenium/webdriver/edge/bridge.rb', line 104 def window_position(handle = :current) data = execute :get_window_position, window_handle: handle Point.new data['x'], data['y'] 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.
92 93 94 95 96 |
# File 'lib/selenium/webdriver/edge/bridge.rb', line 92 def window_size(handle = :current) data = execute :get_window_size, window_handle: handle Dimension.new data['width'], data['height'] end |