File tree 1 file changed +21
-0
lines changed
src/AppiumLibrary/keywords
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,27 @@ def click_button(self, index_or_name):
49
49
class_name = self ._get_class (_platform_class_dict )
50
50
self ._click_element_by_class_name (class_name , index_or_name )
51
51
52
+ def click_text (self , text , exact_match = False ):
53
+ """Click text identified by ``text``.
54
+
55
+ By default tries to click any text involves given ``text``, if you would
56
+ like to click exactly matching text, then set ``exact_match`` to `True`.
57
+
58
+ If there are multiple use of ``text`` use `Get Web Elements`.
59
+
60
+ New in AppiumLibrary 1.4.
61
+ """
62
+ _platform_class_dict = {'ios' : 'name' , 'android' : 'text' }
63
+ if exact_match :
64
+ _xpath = '//*[@{}="{}"]' .format (
65
+ _platform_class_dict .get (self ._get_platform ()),
66
+ text )
67
+ else :
68
+ _xpath = '//*[contains(@{},"{}")]' .format (
69
+ _platform_class_dict .get (self ._get_platform ()),
70
+ text )
71
+ self ._element_find (_xpath , True , True ).click ()
72
+
52
73
def input_text (self , locator , text ):
53
74
"""Types the given `text` into text field identified by `locator`.
54
75
You can’t perform that action at this time.
0 commit comments