Skip to content

Commit 4bb466f

Browse files
Add txt methods
Fix #7
1 parent 2d2704a commit 4bb466f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/appium_lib/helper.rb

+15-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ def wait &block
2929
result
3030
end
3131

32+
# Return the first element matching text.
33+
# @param text [String] the text to search for
34+
# @return [Element] the first matching element
35+
def txt text
36+
txts(text).first
37+
end
38+
39+
# Return all elements matching text.
40+
# @param text [String] the text to search for
41+
# @return [Array<Element>] all matching elements
42+
def txts text
43+
$driver.find_elements :xpath, "//*[contains(@text, '#{text}')]"
44+
end
45+
3246
# Return the first element matching name.
3347
# on Android name is content description
3448
# on iOS name is the accessibility label or the text.
@@ -38,7 +52,7 @@ def name name
3852
$driver.find_element :name, name
3953
end
4054

41-
# Return all element matching name.
55+
# Return all elements matching name.
4256
# on Android name is content description
4357
# on iOS name is the accessibility label or the text.
4458
# @param name [String] the name to search for

0 commit comments

Comments
 (0)