Varun Bali Varun Bali - 1 year ago 169
iOS Question

Appium: How to scroll down drop down in an iOS app using Java

My objective is scroll down through the drop down until the state such as TN is visible to the user. This was possible in Appium when scrollTo() methods were working but they are deprecated in the current Appium build. I tried driver.swipe() but nothing happens. I am not well versed with iOS Predicates but tried using those too.

enter image description here

Alternatives tried so far but none worked:


MobileElement element = wd.findElementByIosUIAutomation(
".tableViews()[0]" + ".scrollToElementWithPredicate(\"name CONTAINS 'TN'\")");
element.tap(1, 1);


JavascriptExecutor js = (JavascriptExecutor) wd; HashMap <String, String> scrollObject = new HashMap <String, String>();
scrollObject.put("element", ((RemoteWebElement)
wd.findElementByAccessibilityId("TN")).getId()); js.executeScript(
"mobile: scroll", scrollObject);

Answer Source

Ok I figured out the solution but it was very difficult to find considering the lack of solutions:

String path = "UIATarget.localTarget().frontMostApp().mainWindow().popover().tableViews()[0].cells()[\"TN\"]";
driver.executeScript(path + ".scrollToVisible();");

MobileElement state = driver.findElementByIosUIAutomation(path);
state.tap(1, 1);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download