Skip to content

Commit

Permalink
click text keyword added.
Browse files Browse the repository at this point in the history
  • Loading branch information
serhatbolsu committed Oct 11, 2016
1 parent 7ff445c commit f8df36b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/AppiumLibrary/keywords/_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,27 @@ def click_button(self, index_or_name):
class_name = self._get_class(_platform_class_dict)
self._click_element_by_class_name(class_name, index_or_name)

def click_text(self, text, exact_match=False):
"""Click text identified by ``text``.
By default tries to click any text involves given ``text``, if you would
like to click exactly matching text, then set ``exact_match`` to `True`.
If there are multiple use of ``text`` use `Get Web Elements`.
New in AppiumLibrary 1.4.
"""
_platform_class_dict = {'ios': 'name', 'android': 'text'}
if exact_match:
_xpath = '//*[@{}="{}"]'.format(
_platform_class_dict.get(self._get_platform()),
text)
else:
_xpath = '//*[contains(@{},"{}")]'.format(
_platform_class_dict.get(self._get_platform()),
text)
self._element_find(_xpath, True, True).click()

def input_text(self, locator, text):
"""Types the given `text` into text field identified by `locator`.
Expand Down

0 comments on commit f8df36b

Please sign in to comment.