June 2017
Intermediate to advanced
256 pages
5h 38m
English
One of the most commonly used gestures on mobiles is scroll. Earlier, there were two methods available for scrolling: scrollTo(String text) and ScrollToExact(String text). However, recently, both functions have been deprecated. To solve this, we can use swipe to perform the scroll functions and pass in parameters that are based on the relative height and width of the screen.
To scroll down, use the following code snippet, where we have fixed the x component and moved the y component:
public void scrollDown() { int height = driver.manage().window().getSize().getHeight(); androidDriver.swipe(5, height * 2 / 3, 5, height / 3, 1000);}
To scroll up, use this code snippet where we have fixed the x component and moved the y component:
Read now
Unlock full access