diff --git a/AppiumLibrary/__init__.py b/AppiumLibrary/__init__.py index 2d4484a4..c8e85937 100644 --- a/AppiumLibrary/__init__.py +++ b/AppiumLibrary/__init__.py @@ -63,6 +63,8 @@ class AppiumLibrary( | chain | Click Element `|` chain=XCUIElementTypeWindow[1]/* | Matches by iOS Class Chain | | | css | Click Element `|` css=.green_button | Matches by css in webview | | | name | Click Element `|` name=my_element | Matches by @name attribute | *Only valid* for Selendroid | + | imagef | Click Element `|` imagef=path/to/image/file | Matches by image | Only Available for NATIVE \ + Context - Check PR: #291 | == Using webelements == diff --git a/AppiumLibrary/locators/elementfinder.py b/AppiumLibrary/locators/elementfinder.py index c3a5dd07..ed50a65a 100644 --- a/AppiumLibrary/locators/elementfinder.py +++ b/AppiumLibrary/locators/elementfinder.py @@ -10,6 +10,7 @@ def __init__(self): self._strategies = { 'identifier': self._find_by_identifier, 'id': self._find_by_id, + 'imagef': self._find_by_image, 'name': self._find_by_name, 'xpath': self._find_by_xpath, 'class': self._find_by_class_name, @@ -119,6 +120,12 @@ def _find_by_chain(self, browser, criteria, tag, constraints): browser.find_elements_by_ios_class_chain(criteria), tag, constraints) + def _find_by_image(self, browser, criteria, tag, constraints): + """Find element matches by image file.""" + return self._filter_elements( + browser.find_elements_by_image(criteria), + tag, constraints) + def _find_by_default(self, browser, criteria, tag, constraints): if criteria.startswith('//'): return self._find_by_xpath(browser, criteria, tag, constraints) diff --git a/docs/AppiumLibrary.html b/docs/AppiumLibrary.html index e28040d7..8ac0a9b2 100644 --- a/docs/AppiumLibrary.html +++ b/docs/AppiumLibrary.html @@ -6,7 +6,7 @@ - +