Scroll Page to An Object in Appium
For some people, scrolling a page in Appium maybe not a big deal, but I found it very hard to scroll a page for my Company’s app. A few days ago, I tried to build an automation test for Traveloka app. However, I realised that Appium can only detect an element that is shown in the screen. I’ve tried many methods to scroll the screen, but no one worked for me. After browsing the solution for several hours, finally I found a workaround that is work for my issue.
So, the problem is I want to scroll this page:
To click the orange button:
To solve this issue, I use the following code:
AppiumDriver wd = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities); // The magic code! wd.scrollTo("CONTINUE");
As you can see that Appium will looking for a CONTINUE string in the screen and it will stop scrolling after the string is found. This way, I can click on the button because it has appeared on the screen.
Hope this is helpful and good luck with your case! 🙂