9
9
name defaults to label when undefined. value is never a default so that must be
10
10
included in a new search.
11
11
12
+ Find - search everything.
13
+
12
14
The search order is:
13
15
1. name
14
16
2. label (implied by name)
15
17
3. value
18
+
16
19
=end
17
20
18
21
# Return the first element matching text.
19
22
# @param text [String] the text to search for
20
23
# @return [Element] the first matching element
21
- def text text
24
+ def find text
22
25
# returnElems requires a wrapped $(element).
23
26
# set to empty array when length is zero to prevent hang.
24
27
js = %Q(
25
28
var eles = au.mainWindow.elements();
26
- var a = eles.firstWithPredicate("name contains[c] '#{ text } '");
29
+ var a = eles.firstWithPredicate("name contains[c] '#{ text } ' || label contains[c] ' #{ text } ' || value contains[c] ' #{ text } ' ");
27
30
if ( a.length === 0 ) {
28
- a = eles.firstWithPredicate("value contains[c] '#{ text } '");
29
- if ( a.length === 0 ) {
30
- a = [];
31
- }
31
+ a = [];
32
32
}
33
33
au._returnElems($(a));
34
34
)
@@ -39,13 +39,12 @@ def text text
39
39
# Return all elements matching text.
40
40
# @param text [String] the text to search for
41
41
# @return [Array<Element>] all matching elements
42
- def texts text
42
+ def finds text
43
43
# returnElems requires a wrapped $(element).
44
44
# must call toArray when using withPredicate instead of firstWithPredicate.
45
45
js = %Q(
46
46
var eles = au.mainWindow.elements();
47
- var a = eles.withPredicate("name contains[c] '#{ text } '").toArray();
48
- a = a.concat( eles.withPredicate("value contains[c] '#{ text } '").toArray() );
47
+ var a = eles.withPredicate("name contains[c] '#{ text } ' || label contains[c] '#{ text } ' || value contains[c] '#{ text } '").toArray();
49
48
if ( a.length === 0 ) {
50
49
a = [];
51
50
}
@@ -55,22 +54,4 @@ def texts text
55
54
execute_script js
56
55
end
57
56
58
- # Return the first element matching name.
59
- # on Android name is content description
60
- # on iOS name is the accessibility label or the text.
61
- # @param name [String] the name to search for
62
- # @return [Element] the first matching element
63
- def name name
64
- text name
65
- end
66
-
67
- # Return all elements matching name.
68
- # on Android name is content description
69
- # on iOS name is the accessibility label or the text.
70
- # @param name [String] the name to search for
71
- # @return [Array<Element>] all matching elements
72
- def names name
73
- texts name
74
- end
75
-
76
57
end # if ios
0 commit comments