@@ -29,30 +29,34 @@ def finds_exact(value)
29
29
end
30
30
31
31
# @private
32
- def scroll_uiselector ( content )
33
- "new UiScrollable(new UiSelector().scrollable(true).instance(0 )).scrollIntoView(#{ content } .instance(0));"
32
+ def scroll_uiselector ( content , index = 0 )
33
+ "new UiScrollable(new UiSelector().scrollable(true).instance(#{ index } )).scrollIntoView(#{ content } .instance(0));"
34
34
end
35
35
36
36
# Scroll to the first element containing target text or description.
37
- # @param text [String] the text to search for in the text value and content description
37
+ # @param text [String] the text or resourceId to search for in the text value and content description
38
+ # @param scrollable_index [Integer] the index for scrollable views.
38
39
# @return [Element] the element scrolled to
39
- def scroll_to ( text )
40
+ def scroll_to ( text , scrollable_index = 0 )
40
41
text = %("#{ text } ")
41
42
42
- args = scroll_uiselector ( "new UiSelector().textContains(#{ text } )" ) +
43
- scroll_uiselector ( "new UiSelector().descriptionContains(#{ text } )" )
43
+ args = scroll_uiselector ( "new UiSelector().textContains(#{ text } )" , scrollable_index ) +
44
+ scroll_uiselector ( "new UiSelector().descriptionContains(#{ text } )" , scrollable_index ) +
45
+ scroll_uiselector ( resource_id ( text , "new UiSelector().resourceId(#{ text } );" ) , scrollable_index )
44
46
45
47
find_element :uiautomator , args
46
48
end
47
49
48
50
# Scroll to the first element with the exact target text or description.
49
- # @param text [String] the text to search for in the text value and content description
51
+ # @param text [String] the text or resourceId to search for in the text value and content description
52
+ # @param scrollable_index [Integer] the index for scrollable views.
50
53
# @return [Element] the element scrolled to
51
- def scroll_to_exact ( text )
54
+ def scroll_to_exact ( text , scrollable_index = 0 )
52
55
text = %("#{ text } ")
53
56
54
- args = scroll_uiselector ( "new UiSelector().text(#{ text } )" ) +
55
- scroll_uiselector ( "new UiSelector().description(#{ text } )" )
57
+ args = scroll_uiselector ( "new UiSelector().text(#{ text } )" , scrollable_index ) +
58
+ scroll_uiselector ( "new UiSelector().description(#{ text } )" , scrollable_index ) +
59
+ scroll_uiselector ( resource_id ( text , "new UiSelector().resourceId(#{ text } );" ) , scrollable_index )
56
60
57
61
find_element :uiautomator , args
58
62
end
0 commit comments