File tree 3 files changed +17
-13
lines changed
android_tests/lib/android/specs/common
3 files changed +17
-13
lines changed Original file line number Diff line number Diff line change 61
61
strs . has_key? ( "activity_save_restore" ) . must_equal true
62
62
end
63
63
64
+ def must_return_element element
65
+ element . class . must_equal Selenium ::WebDriver ::Element
66
+ end
67
+
64
68
t 'complex_find' do
65
- act = complex_find [ [ [ 3 , 'Accessibility' ] , [ 14 , true ] ] ]
66
- act . class . must_equal Selenium ::WebDriver ::Element
69
+ find ( 'Views' ) . click
70
+ must_return_element complex_find ( mode : 'scroll' , selectors : [ [ [ 3 , 'tabs' ] ] ] )
71
+ must_return_element complex_find ( mode : 'all' , selectors : [ [ [ 3 , 'i' ] ] ] ) . first
72
+ must_return_element complex_find ( selectors : [ [ [ 3 , 'tabs' ] ] ] )
73
+ back
67
74
end
68
75
69
76
t 'key_event' do
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ def scroll_to text
27
27
# descriptionContains(text)
28
28
[ [ 7 , text ] ]
29
29
30
- complex_find 'scroll' , args
30
+ complex_find mode : 'scroll' , selectors : args
31
31
end
32
32
33
33
# Scroll to an element with the exact target text or description.
@@ -40,7 +40,7 @@ def scroll_to_exact text
40
40
# description(text)
41
41
[ [ 5 , text ] ]
42
42
43
- complex_find 'scroll' , args
43
+ complex_find mode : 'scroll' , selectors : args
44
44
end
45
45
end # module Android
46
46
end # module Appium
Original file line number Diff line number Diff line change @@ -140,18 +140,15 @@ def key_event(key, metastate=nil)
140
140
end
141
141
142
142
add_endpoint_method ( :complex_find , 'session/:session_id/appium/app/complex_find' ) do
143
- def complex_find ( mode , selectors = nil )
144
- if selectors . nil?
145
- selectors = mod . dup
146
- mod = false
147
- end
148
-
149
- selector_array = mod ? [ mod ] : [ ]
150
- selector_array . push selectors
143
+ def complex_find ( opts )
144
+ mode = opts . fetch :mode , false
145
+ selectors = opts . fetch :selectors , false
146
+ raise 'Complex find must have selectors' unless selectors
147
+ selectors . insert ( 0 , mode ) if mode
151
148
152
149
ids = execute :complex_find , { } , selectors
153
- if mod && ids . length > 1
154
150
151
+ if mode == 'all' && ids . length > 1
155
152
return ids . map { |id | Selenium ::WebDriver ::Element . new self , element_id_from ( id ) }
156
153
else
157
154
return Selenium ::WebDriver ::Element . new self , element_id_from ( ids )
You can’t perform that action at this time.
0 commit comments