I am trying to scroll to an element using the following code:
@AndroidFindBy(uiAutomator=“new UiScrollable(new UiSelector()).scrollIntoView(” + “new UiSelector().text(“Contacts”));”)
@iOSFindBy(uiAutomator=“new UiScrollable(new UiSelector()).scrollIntoView(” + “new UiSelector().text(“Contacts”));”)
public MobileElement orgContact;
This works perfectly in Android but on iOS I get the following error:
org.openqa.selenium.NoSuchElementException: Can’t locate an element by this strategy: Locator map:
- native content: “By.IosUIAutomation: new UiScrollable(new UiSelector()).scrollIntoView(new UiSelector().text(“Contacts”));”
I have also tried to scroll using:
public void verticalScroll(AppiumDriver driver) {
this.driver=driver;
dimensions = driver.manage().window().getSize();
Double screenHeightStart = dimensions.getHeight() * 0.5;
int scrollStart = screenHeightStart.intValue();
System.out.println("s="+scrollStart);
Double screenHeightEnd = dimensions.getHeight() * 0.2;
int scrollEnd = screenHeightEnd.intValue();
driver.swipe(0,scrollStart,0,scrollEnd,5000);
}
But it also does not work.
Can anyone please suggest what am I doing wrong here