Class: Appium::Core::Base::Bridge::W3C
- Inherits:
-
Selenium::WebDriver::Remote::W3C::Bridge
- Object
- Selenium::WebDriver::Remote::W3C::Bridge
- Appium::Core::Base::Bridge::W3C
- Defined in:
- lib/appium_lib_core/common/base/bridge/w3c.rb
Instance Method Summary collapse
-
#available_log_types ⇒ Object
logs.
- #commands(command) ⇒ Object
-
#element_attribute(element, name) ⇒ Object
For Appium override.
-
#find_element_by(how, what, parent = nil) ⇒ Object
For Appium override.
- #find_element_by_image(full_image:, partial_image:, match_threshold: nil, visualize: false) ⇒ ::Appium::Core::ImageElement|nil
-
#find_elements_by(how, what, parent = nil) ⇒ Object
For Appium override.
- #find_elements_by_image(full_image:, partial_images:, match_threshold: nil, visualize: false) ⇒ []|[::Appium::Core::ImageElement]
-
#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.
-
#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.
-
#session_capabilities ⇒ Object
Port from MJSONWP.
-
#set_location(lat, lon, alt) ⇒ Object
For Appium No implementation for W3C webdriver module called in ‘extend DriverExtensions::HasLocation`.
- #take_element_screenshot(element) ⇒ Object
Instance Method Details
#available_log_types ⇒ Object
logs
For Appium No implementation for W3C webdriver module
188 189 190 191 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 188 def available_log_types types = execute :get_available_log_types Array(types).map(&:to_sym) end |
#commands(command) ⇒ Object
12 13 14 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 12 def commands(command) ::Appium::Core::Commands::W3C::COMMANDS[command] end |
#element_attribute(element, name) ⇒ Object
For Appium override
56 57 58 59 60 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 56 def element_attribute(element, name) # For W3C # execute_atom :getAttribute, element, name execute :get_element_attribute, id: element.ref, name: name end |
#find_element_by(how, what, parent = nil) ⇒ Object
For Appium override
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 64 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_element_by_image(full_image:, partial_image:, match_threshold: nil, visualize: false) ⇒ ::Appium::Core::ImageElement|nil
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 93 def find_element_by_image(full_image:, partial_image:, match_threshold: nil, visualize: false) = {} [:threshold] = match_threshold unless match_threshold.nil? [:visualize] = visualize params = {} params[:mode] = :matchTemplate params[:firstImage] = full_image params[:secondImage] = partial_image params[:options] = if result = execute(:compare_images, {}, params) rect = result['rect'] if rect return ::Appium::Core::ImageElement.new(self, rect['x'], rect['y'], rect['width'], rect['height'], result['visualization']) end nil end |
#find_elements_by(how, what, parent = nil) ⇒ Object
For Appium override
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 77 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 |
#find_elements_by_image(full_image:, partial_images:, match_threshold: nil, visualize: false) ⇒ []|[::Appium::Core::ImageElement]
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 122 def find_elements_by_image(full_image:, partial_images:, match_threshold: nil, visualize: false) = {} [:threshold] = match_threshold unless match_threshold.nil? [:visualize] = visualize params = {} params[:mode] = :matchTemplate params[:firstImage] = full_image params[:options] = if partial_images.each_with_object([]) do |partial_image, acc| params[:secondImage] = partial_image begin result = execute(:compare_images, {}, params) rect = result['rect'] if result['rect'] acc.push ::Appium::Core::ImageElement.new(self, rect['x'], rect['y'], rect['width'], rect['height'], result['visualization']) end rescue ::Selenium::WebDriver::Error::WebDriverError => e acc if e..include?('Cannot find any occurrences') end end end |
#get_timeouts ⇒ Object
Port from MJSONWP
35 36 37 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 35 def get_timeouts execute :get_timeouts end |
#location ⇒ Object
For Appium No implementation for W3C webdriver module called in ‘extend DriverExtensions::HasLocation`
170 171 172 173 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 170 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
195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 195 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 |
#network_connection ⇒ Object
For Appium override called in ‘extend DriverExtensions::HasNetworkConnection`
156 157 158 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 156 def network_connection execute :get_network_connection end |
#network_connection=(type) ⇒ Object
For Appium override called in ‘extend DriverExtensions::HasNetworkConnection`
163 164 165 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 163 def network_connection=(type) execute :set_network_connection, {}, { parameters: { type: type } } end |
#page_source ⇒ Object
For Appium override
46 47 48 49 50 51 52 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 46 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 |
#session_capabilities ⇒ Object
Port from MJSONWP
40 41 42 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 40 def session_capabilities ::Selenium::WebDriver::Remote::W3C::Capabilities.json_create execute(:get_capabilities) end |
#set_location(lat, lon, alt) ⇒ Object
For Appium No implementation for W3C webdriver module called in ‘extend DriverExtensions::HasLocation`
178 179 180 181 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 178 def set_location(lat, lon, alt) loc = { latitude: lat, longitude: lon, altitude: alt } execute :set_location, {}, { location: loc } end |
#take_element_screenshot(element) ⇒ Object
207 208 209 |
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 207 def take_element_screenshot(element) execute :take_element_screenshot, id: element.ref end |