Class: Appium::Core::Base::Bridge::MJSONWP
- Inherits:
-
Selenium::WebDriver::Remote::OSS::Bridge
- Object
- Selenium::WebDriver::Remote::OSS::Bridge
- Appium::Core::Base::Bridge::MJSONWP
- Includes:
- Device::AppManagement, Device::AppState, Device::Context, Device::Device, Device::DeviceLock, Device::FileManagement, Device::ImageComparison, Device::ImeActions, Device::KeyEvent, Device::Keyboard, Device::ScreenRecord::Command, Device::Setting, Device::TouchActions, Device::Value
- Defined in:
- lib/appium_lib_core/common/base/bridge/mjsonwp.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
- #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
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
#commands(command) ⇒ Object
21 22 23 |
# File 'lib/appium_lib_core/common/base/bridge/mjsonwp.rb', line 21 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
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/appium_lib_core/common/base/bridge/mjsonwp.rb', line 29 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]
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/appium_lib_core/common/base/bridge/mjsonwp.rb', line 58 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
89 90 91 |
# File 'lib/appium_lib_core/common/base/bridge/mjsonwp.rb', line 89 def take_element_screenshot(element) execute :take_element_screenshot, id: element.ref end |