Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Release tags are https://github.com/appium/ruby_lib/releases .
### 1. Enhancements
- add `mobile: installCertificate` shortcut for XCUITest
- add `mobile: getContexts` shortcut for XCUITest
- Add `find_element_by_image` and `find_elements_by_image` to handle `ImageElement`
- Read a [PR](https://github.com/appium/ruby_lib/pull/795/files) and [Core](https://github.com/appium/ruby_lib_core/blob/master/CHANGELOG.md#enhancements-1) for more details
- Experimental feature

### 2. Bug fixes

Expand Down
2 changes: 1 addition & 1 deletion appium_lib.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.homepage = 'https://github.com/appium/ruby_lib' # published as appium_lib
s.require_paths = ['lib']

s.add_runtime_dependency 'appium_lib_core', '~> 1.7.0'
s.add_runtime_dependency 'appium_lib_core', '~> 1.7.2'
s.add_runtime_dependency 'tomlrb', '~> 1.1'
s.add_runtime_dependency 'nokogiri', '~> 1.8', '>= 1.8.1'

Expand Down
37 changes: 37 additions & 0 deletions lib/appium_lib/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,43 @@ def find_element(*args)
@driver.find_element(*args)
end

# Return ImageElement if current view has a partial image
#
# @param [String] png_img_path A path to a partial image you'd like to find
# @param [Flood] match_threshold At what normalized threshold to reject
# @param [Bool] visualize Makes the endpoint to return an image, which contains the visualized result of
# the corresponding picture matching operation. This option is disabled by default.
#
# @return [::Appium::Core::ImageElement]
# @raise [::Appium::Core::Error::NoSuchElementError|::Appium::Core::Error::CoreError] No such element
#
# @example
#
# @driver.find_element_by_image './test/functional/data/test_element_image.png'
#
DEFAULT_MATCH_THRESHOLD = 0.5
def find_element_by_image(png_img_path, match_threshold: DEFAULT_MATCH_THRESHOLD, visualize: false)
@driver.find_element_by_image(png_img_path, match_threshold: match_threshold, visualize: visualize)
end

# Return ImageElement if current view has partial images
#
# @param [[String]] png_img_paths Paths to a partial image you'd like to find
# @param [Flood] match_threshold At what normalized threshold to reject
# @param [Bool] visualize Makes the endpoint to return an image, which contains the visualized result of
# the corresponding picture matching operation. This option is disabled by default.
#
# @return [[::Appium::Core::ImageElement]]
# @return [::Appium::Core::Error::CoreError]
#
# @example
#
# @driver.find_elements_by_image ['./test/functional/data/test_element_image.png']
#
def find_elements_by_image(png_img_paths, match_threshold: DEFAULT_MATCH_THRESHOLD, visualize: false)
@driver.find_elements_by_image(png_img_paths, match_threshold: match_threshold, visualize: visualize)
end

# Calls @driver.set_location
#
# @note This method does not work on real devices.
Expand Down