scrollUntilVisible
To scroll towards a direction until an element becomes visible in the view hierarchy, use the following command:
Please refer to the Selectors page for a full list of supported selectors.
Direction
The scroll will move towards the direction specified DOWN|UP|LEFT|RIGHT
. For example, if DOWN
is specified then it will start scrolling towards the bottom of the screen.
Timeout
The timeout (in miliseconds) defines how long it should scroll and look for the specified element. The test fails if the timeout ends before the specified element is visible. If the element is visible, the test will move on with the next command / step.
Center Element
If enabled, it will attempt to stop when the element is closer to the screen center.
In case it's not possible to bring the element to the center (i.e it's the last element in the list), it will stop scrolling after few attempts.
Visibility Percentage
By default an element will be considered visible if it is fully displayed in the viewport. You can adjust that threshold by modifying visibilityPercentage
.
Example
If you want to scroll until the text "My text" is visible you can run the following command:
If we want to scroll towards the bottom until a view with id com.example.resource.some_view_id
becomes visible, you can use the id
selector like this:
Last updated