Class: Appium::Core::Base::Bridge::MJSONWP
- Inherits:
-
Selenium::WebDriver::Remote::OSS::Bridge
- Object
- Selenium::WebDriver::Remote::OSS::Bridge
- Appium::Core::Base::Bridge::MJSONWP
- Defined in:
- lib/appium_lib_core/common/base/bridge/mjsonwp.rb
Instance Method Summary collapse
- #commands(command) ⇒ Object
- #find_element_by_image(full_image:, partial_image:, match_threshold: nil, visualize: false) ⇒ ::Appium::Core::ImageElement|nil
- #find_elements_by_image(full_image:, partial_images:, match_threshold: nil, visualize: false) ⇒ []|[::Appium::Core::ImageElement]
- #take_element_screenshot(element) ⇒ Object
Instance Method Details
#commands(command) ⇒ Object
6 7 8 |
# File 'lib/appium_lib_core/common/base/bridge/mjsonwp.rb', line 6 def commands(command) ::Appium::Core::Commands::MJSONWP::COMMANDS[command] end |
#find_element_by_image(full_image:, partial_image:, match_threshold: nil, visualize: false) ⇒ ::Appium::Core::ImageElement|nil
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/appium_lib_core/common/base/bridge/mjsonwp.rb', line 14 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_image(full_image:, partial_images:, match_threshold: nil, visualize: false) ⇒ []|[::Appium::Core::ImageElement]
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/appium_lib_core/common/base/bridge/mjsonwp.rb', line 43 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 |
#take_element_screenshot(element) ⇒ Object
74 75 76 |
# File 'lib/appium_lib_core/common/base/bridge/mjsonwp.rb', line 74 def take_element_screenshot(element) execute :take_element_screenshot, id: element.ref end |