Class: Appium::Core::Base::Bridge::W3C
- Inherits:
-
Selenium::WebDriver::Remote::W3C::Bridge
- Object
- Selenium::WebDriver::Remote::W3C::Bridge
- Appium::Core::Base::Bridge::W3C
- Includes:
- Device::AppManagement, Device::AppState, Device::Context, Device::Device, Device::DeviceLock, Device::ExecuteDriver, Device::FileManagement, Device::ImageComparison, Device::ImeActions, Device::KeyEvent, Device::Keyboard, Device::Orientation, Device::ScreenRecord::Command, Device::Setting, Device::TouchActions, Device::Value
- Defined in:
- lib/appium_lib_core/common/base/bridge/w3c.rb
Constant Summary
Constants included from Device::AppState
Constants included from Device::ImageComparison
Device::ImageComparison::GET_SIMILARITY, Device::ImageComparison::MATCH_FEATURES, Device::ImageComparison::MATCH_TEMPLATE, Device::ImageComparison::MODE
Instance Method Summary collapse
-
#action(async = false) ⇒ Object
Perform touch actions for W3C module.
-
#available_log_types ⇒ Object
logs.
- #commands(command) ⇒ Object
-
#convert_to_element(id) ⇒ ::Selenium::WebDriver::Element
For Appium.
-
#element_attribute(element, name) ⇒ Object
For Appium override.
-
#element_displayed?(element) ⇒ Boolean
For Appium override.
-
#find_element_by(how, what, parent = nil) ⇒ Object
For Appium override.
-
#find_elements_by(how, what, parent = nil) ⇒ Object
For Appium override.
-
#get_timeouts ⇒ Object
Port from MJSONWP.
-
#location ⇒ Object
For Appium No implementation for W3C webdriver module called in ‘extend DriverExtensions::HasLocation’.
-
#log(type) ⇒ Object
For Appium No implementation for W3C webdriver module.
-
#log_event(vendor, event) ⇒ Object
For Appium.
-
#log_events(type = nil) ⇒ Object
For Appium.
-
#network_connection ⇒ Object
For Appium override called in ‘extend DriverExtensions::HasNetworkConnection’.
-
#network_connection=(type) ⇒ Object
For Appium override called in ‘extend DriverExtensions::HasNetworkConnection’.
-
#page_source ⇒ Object
For Appium override.
-
#send_keys_to_active_element(key) ⇒ Object
Port from MJSONWP.
-
#session_capabilities ⇒ Object
Port from MJSONWP.
-
#sessions ⇒ Object
Returns all available sessions on the Appium server instance.
-
#set_location(lat, lon, alt = 0.0) ⇒ Object
For Appium No implementation for W3C webdriver module called in extend DriverExtensions::HasLocation It has below code as well.
- #status ⇒ Object
- #take_element_screenshot(element) ⇒ Object
- #take_viewport_screenshot ⇒ Object
Methods included from Device::Orientation
#screen_orientation, #screen_orientation=
Methods included from Device::ExecuteDriver
Methods included from Device::TouchActions
Methods included from Device::Device
Methods included from Device::ScreenRecord::Command
#stop_and_save_recording_screen, #stop_recording_screen
Methods included from Device::AppState
Methods included from Device::AppManagement
#activate_app, #app_installed?, #app_strings, #background_app, #close_app, #install_app, #launch_app, #remove_app, #reset, #terminate_app
Methods included from Device::ImageComparison
#compare_images, #find_image_occurrence, #get_images_similarity, #match_images_features
Methods included from Device::KeyEvent
#keyevent, #long_press_keycode, #press_keycode
Methods included from Device::FileManagement
#pull_file, #pull_folder, #push_file
Methods included from Device::Value
#replace_value, #set_immediate_value
Methods included from Device::Context
#available_contexts, #current_context, #set_context, #switch_to_default_context, #within_context
Methods included from Device::Setting
#get_settings, #update_settings
Methods included from Device::ImeActions
#ime_activate, #ime_activated, #ime_active_engine, #ime_available_engines, #ime_deactivate
Methods included from Device::Keyboard
#hide_keyboard, #is_keyboard_shown
Methods included from Device::DeviceLock
#device_locked?, #lock, #unlock
Instance Method Details
#action(async = false) ⇒ Object
Perform touch actions for W3C module. Generate touch pointer action here and users can use this via driver.action
-
seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/W3CActionBuilder.html
-
seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/PointerActions.html
-
seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/KeyActions.html
‘mouse’ action is by default in the Ruby client. Appium server force the mouse action to touch once in the server side. So we don’t consider the case.
64 65 66 67 68 69 70 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 64 def action(async = false) # Used for default duration of each touch actions # Override from 250 milliseconds to 50 milliseconds action_builder = super action_builder.default_move_duration = 0.05 action_builder end |
#available_log_types ⇒ Object
logs
For Appium No implementation for W3C webdriver module
193 194 195 196 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 193 def available_log_types types = execute :get_available_log_types Array(types).map(&:to_sym) end |
#commands(command) ⇒ Object
37 38 39 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 37 def commands(command) ::Appium::Core::Commands::W3C::COMMANDS[command] end |
#convert_to_element(id) ⇒ ::Selenium::WebDriver::Element
For Appium
145 146 147 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 145 def convert_to_element(id) ::Selenium::WebDriver::Element.new self, element_id_from(id) end |
#element_attribute(element, name) ⇒ Object
For Appium override
109 110 111 112 113 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 109 def element_attribute(element, name) # For W3C in Selenium Client # execute_atom :getAttribute, element, name execute :get_element_attribute, id: element.ref, name: name end |
#element_displayed?(element) ⇒ Boolean
For Appium override
100 101 102 103 104 105 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 100 def element_displayed?(element) # For W3C # https://github.com/SeleniumHQ/selenium/commit/b618499adcc3a9f667590652c5757c0caa703289 # execute_atom :isDisplayed, element execute :is_element_displayed, id: element.ref end |
#find_element_by(how, what, parent = nil) ⇒ Object
For Appium override
117 118 119 120 121 122 123 124 125 126 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 117 def find_element_by(how, what, parent = nil) how, what = convert_locators(how, what) id = if parent execute :find_child_element, { id: parent }, { using: how, value: what } else execute :find_element, {}, { using: how, value: what } end ::Selenium::WebDriver::Element.new self, element_id_from(id) end |
#find_elements_by(how, what, parent = nil) ⇒ Object
For Appium override
130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 130 def find_elements_by(how, what, parent = nil) how, what = convert_locators(how, what) ids = if parent execute :find_child_elements, { id: parent }, { using: how, value: what } else execute :find_elements, {}, { using: how, value: what } end ids.map { |id| ::Selenium::WebDriver::Element.new self, element_id_from(id) } end |
#get_timeouts ⇒ Object
Port from MJSONWP
73 74 75 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 73 def get_timeouts execute :get_timeouts end |
#location ⇒ Object
For Appium No implementation for W3C webdriver module called in ‘extend DriverExtensions::HasLocation’
166 167 168 169 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 166 def location obj = execute(:get_location) || {} ::Selenium::WebDriver::Location.new obj['latitude'], obj['longitude'], obj['altitude'] end |
#log(type) ⇒ Object
For Appium No implementation for W3C webdriver module
200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 200 def log(type) data = execute :get_log, {}, { type: type.to_s } Array(data).map do |l| begin ::Selenium::WebDriver::LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message') rescue KeyError next end end end |
#log_event(vendor, event) ⇒ Object
For Appium
213 214 215 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 213 def log_event(vendor, event) execute :post_log_event, {}, { vendor: vendor, event: event } end |
#log_events(type = nil) ⇒ Object
For Appium
218 219 220 221 222 223 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 218 def log_events(type = nil) args = {} args['type'] = type unless type.nil? execute :get_log_events, {}, args end |
#network_connection ⇒ Object
For Appium override called in ‘extend DriverExtensions::HasNetworkConnection’
152 153 154 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 152 def network_connection execute :get_network_connection end |
#network_connection=(type) ⇒ Object
For Appium override called in ‘extend DriverExtensions::HasNetworkConnection’
159 160 161 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 159 def network_connection=(type) execute :set_network_connection, {}, { parameters: { type: type } } end |
#page_source ⇒ Object
For Appium override
90 91 92 93 94 95 96 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 90 def page_source # For W3C # execute_script('var source = document.documentElement.outerHTML;' \ # 'if (!source) { source = new XMLSerializer().serializeToString(document); }' \ # 'return source;') execute :get_page_source end |
#send_keys_to_active_element(key) ⇒ Object
Port from MJSONWP
83 84 85 86 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 83 def send_keys_to_active_element(key) text = ::Selenium::WebDriver::Keys.encode(key).join('') execute :send_keys_to_active_element, {}, { value: text.split(//) } end |
#session_capabilities ⇒ Object
Port from MJSONWP
78 79 80 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 78 def session_capabilities ::Selenium::WebDriver::Remote::W3C::Capabilities.json_create execute(:get_capabilities) end |
#sessions ⇒ Object
Returns all available sessions on the Appium server instance
42 43 44 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 42 def sessions execute :get_all_sessions end |
#set_location(lat, lon, alt = 0.0) ⇒ Object
For Appium No implementation for W3C webdriver module called in extend DriverExtensions::HasLocation It has below code as well. We should consider the same context in Selenium 4 as backward compatibility.
def location=(loc)
# note: Location = Struct.new(:latitude, :longitude, :altitude)
raise TypeError, "expected #{Location}, got #{loc.inspect}:#{loc.class}" unless loc.is_a?(Location)
@bridge.set_location loc.latitude, loc.longitude, loc.altitude
end
183 184 185 186 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 183 def set_location(lat, lon, alt = 0.0) loc = { latitude: lat, longitude: lon, altitude: alt } execute :set_location, {}, { location: loc } end |
#status ⇒ Object
46 47 48 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 46 def status execute :status end |
#take_element_screenshot(element) ⇒ Object
229 230 231 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 229 def take_element_screenshot(element) execute :take_element_screenshot, id: element.ref end |
#take_viewport_screenshot ⇒ Object
225 226 227 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 225 def execute_script('mobile: viewportScreenshot') end |