public void tapOnScrolledElement(){
List listOfElements = utils().iOSDriver().findElements(org.openqa.selenium.By.id(“idOfList”));
int index = 7;
scrollToElement($(listOfElements().get(index));
}
public WebElement scrollToElementNew(String text) {
System.out.println(" tapPaymentByDescription(): " + text);
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap scrollObject = new HashMap<>();
scrollObject.put("predicateString", "value == '" + text + "'");
js.executeScript("mobile: scroll", scrollObject);
return iOSDriver().findElementByIosNsPredicate("value = '" + text + "'");
}
public void tapOnScrolledElement(WebElement element) {
element.click();
}
The element is found, the text is printed, BUT the error comes with the following: [main] ERROR net.serenitybdd.core.Serenity - An unknown server-side error occurred while processing the command. Original error: Can’t scroll to element that does not exist (WARNING: The server did not provide any stacktrace information)
Is scrollObject.put(“predicateString”, “value == '” + text + “'”); working for you ? @sivanov for me its just scrolling up & down, is it moving to a particular element ?
Hi…
I have used this code for iOS scroll to text. but for me it scroll to the end of the list and keeps on scrolling and not finding the element.
[HTTP] {“script”:“mobile: scroll”,“args”:[{“predicateString”:“value == ‘Turkey’”}]}
[MJSONWP] Calling AppiumDriver.execute() with args: [“mobile: scroll”,[{“predicateString”:“value == ‘Turkey’”}],“77c45bb1-9ee5-4260-851c-284bdc85aace”]
[XCUITest] Executing command ‘execute’… “IT keeps scrolling end of the list”. Please help.