Tried multiple things to get a Table in iOS to scroll to an element off screen.
Here’s what I tried.:
Does not find the scrollable element
driver.findElement(MobileBy.IosUIAutomation(
"new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().text(\"SomeName\"));"));
Element found but does not scroll
MobileElement element = (MobileElement) driver.findElementByXPath("//*[@label='SomeName']");
new TouchAction(driver).tap(new TapOptions().withElement(new ElementOption().withElement(element))).perform();
Seems the basic scrolling down does not work either. But almost exact same code used for swiping works perfect with only X,y values different.
startX = (size.width / 2); startY = (int) (size.height * 0.60); endY = (int) (size.height * 0.30);
action.press(p1.point(startX, startY))
.waitAction(waitOpt.withDuration(Duration.ofMillis(200)))
.moveTo(p1.point(startX, endY)).release().perform();
I’ve even tried with Java calling the Javascript, odd thing is that if I eliminate the line with the element the scrolling happens but just not to the element I want.
MobileElement element = (MobileElement) driver.findElementByXPath("//*[@label='SomeName']");
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "down");
scrollObject.put("element", element.getId());
driver.executeScript("mobile: scroll", scrollObject);
I’m at my wits end nothing on iOS seems to work all the time. Android on the other was super simple to make this work.