'How do I scroll to element in Appium Java client 8.0
I am using Appium Java client 8.0 and I want to make a method that would scroll to element. I wrote myself a code, but it returns an error.
org.openqa.selenium.InvalidSelectorException: Locator Strategy '-android datamatcher' is not supported for this session`
code:
protected WebElement scrollToElement(String toElementDescription) {
return driver.findElement(AppiumBy.androidDataMatcher("new UiScrollable(new UiSelector().scrollable(true))
.scrollIntoView(new UiSelector().description(" + toElementDescription + "));"));
}
where toElementDescription is my element accessibilityId.
Solution 1:[1]
I guess use of description with current activity may take some time , but you can use below two methods and just pass element name.
ThreadLocalDriver.getTLDriver().findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(\""+element+"\").instance(0))"));
ThreadLocalDriver.getTLDriver().findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textMatches(\"" + element + "\").instance(0))"));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Snehal Gajbhiye |
