Hi I want to swipe to an element that is present down in the screen and that is only accessible after scrolling. I have tried the following code.
JavascriptExecutor js = (JavascriptExecutor) driver;
Map<String, Object> params = new HashMap<>();
params.put("direction", "down");
params.put("element", ((RemoteWebElement) driver.findElement(By.name("Hazard"))).getId());
js.executeScript("mobile: swipe", params);
Previously I am able to scroll but not to a particular element. Rather then it just make a predefined scroll by eleminating
params.put("element", ((RemoteWebElement) driver.findElement(By.name("Hazard"))).getId());
. But I want it scroll to a specific element.
I am using
appium version: 1.15.1
java-client: 7.2.0
尝试这个
driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(text(\"WebView\"));").click();
Instead of swipe
operation, you should use scroll
operation.
You can use it like:
JavascriptExecutor js = (JavascriptExecutor) driver;
Map<String, Object> params = new HashMap<>();
params.put("direction", "down");
params.put("element", ((RemoteWebElement) driver.findElement(By.name("Hazard"))).getId());
js.executeScript("mobile: scroll", params);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.