@@ -29,30 +29,34 @@ def finds_exact(value)
2929 end
3030
3131 # @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));"
3434 end
3535
3636 # 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.
3839 # @return [Element] the element scrolled to
39- def scroll_to ( text )
40+ def scroll_to ( text , scrollable_index = 0 )
4041 text = %("#{ text } ")
4142
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 )
4446
4547 find_element :uiautomator , args
4648 end
4749
4850 # 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.
5053 # @return [Element] the element scrolled to
51- def scroll_to_exact ( text )
54+ def scroll_to_exact ( text , scrollable_index = 0 )
5255 text = %("#{ text } ")
5356
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 )
5660
5761 find_element :uiautomator , args
5862 end
0 commit comments