File tree 1 file changed +35
-4
lines changed
lib/appium_lib/element/ios
1 file changed +35
-4
lines changed Original file line number Diff line number Diff line change 16
16
2. label (implied by name)
17
17
3. value
18
18
19
+ The element order is:
20
+ 1. button
21
+ 2. textfield
22
+ 3. secure textfield
23
+ 4. all elements
19
24
=end
20
25
21
26
# Return the first element matching text.
24
29
def find text
25
30
# returnElems requires a wrapped $(element).
26
31
# set to empty array when length is zero to prevent hang.
32
+ #
33
+ # UIAElementNil when not matched
34
+ #
35
+ # 1. secureTextFields
36
+ # 2. textFields
37
+ # 3. buttons
38
+ # 4. elements
27
39
js = %Q(
28
- var eles = au.mainWindow.elements();
29
- var a = eles.firstWithPredicate("name contains[c] '#{ text } ' || label contains[c] '#{ text } ' || value contains[c] '#{ text } '");
40
+ function isNil( a ) {
41
+ return a.type() === 'UIAElementNil';
42
+ }
43
+
44
+ var w = au.mainWindow;
45
+ var search = "name contains[c] '#{ text } ' || label contains[c] '#{ text } ' || value contains[c] '#{ text } '";
46
+ var a = w.secureTextFields().firstWithPredicate(search);
47
+ if ( isNil(a) ) {
48
+ a = w.textFields().firstWithPredicate(search);
49
+ if ( isNil(a) ) {
50
+ a = w.buttons().firstWithPredicate(search);
51
+ if ( isNil(a) ) {
52
+ a = w.elements().firstWithPredicate(search);
53
+ }
54
+ }
55
+ }
56
+
30
57
if ( a.length === 0 ) {
31
58
a = [];
32
59
}
60
+
33
61
au._returnElems($(a));
34
62
)
35
63
@@ -43,11 +71,14 @@ def finds text
43
71
# returnElems requires a wrapped $(element).
44
72
# must call toArray when using withPredicate instead of firstWithPredicate.
45
73
js = %Q(
46
- var eles = au.mainWindow.elements();
47
- var a = eles.withPredicate("name contains[c] '#{ text } ' || label contains[c] '#{ text } ' || value contains[c] '#{ text } '").toArray();
74
+ var w = au.mainWindow;
75
+ var search = "name contains[c] '#{ text } ' || label contains[c] '#{ text } ' || value contains[c] '#{ text } '";
76
+ var a = w.elements().withPredicate(search).toArray();
77
+
48
78
if ( a.length === 0 ) {
49
79
a = [];
50
80
}
81
+
51
82
au._returnElems($(a));
52
83
)
53
84
You can’t perform that action at this time.
0 commit comments