0

I'm using Appium 1.20. I'm trying to find a way to scroll to an element.

public static void scrollToElement(WebElement e) {
    JavascriptExecutor js = driver;
    HashMap scrollObject = new HashMap();
    scrollObject.put("direction", "down");
    scrollObject.put("name", e.getId()); // <-- there is no getId for WebElement.
    js.executeScript("mobile: scroll", scrollObject);
}

Unfortunately, there is no getId() for WebElement.

How do you scroll to an element in Appium 2?

1
  • May I know your targeted platform where you are unable to scroll? Commented Nov 22, 2022 at 5:13

1 Answer 1

0

If it is android, you can use

driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(\"**/Put some text of scroll screen/**\").instance(0))")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.