【发布时间】:2016-04-23 05:25:57
【问题描述】:
我正在使用 appium (java) 自动化 android 应用程序。
为了在原生组件上滚动,我使用 scrollTo() 和 scrollToExact() 方法。
但如果是应用程序内部的 webView;这些方法不起作用。
更新:
这两种方法我也试过了:
public static void scrollNavigation(AppiumDriver<MobileElement> wd, String widID, String target, String direction)
{
JavascriptExecutor js = (JavascriptExecutor) wd;
HashMap<String, String> swipeObject = new HashMap<String, String>();
swipeObject.put("text", target);
swipeObject.put("direction", direction);
swipeObject.put("element", widID);
js.executeScript("mobile: scrollTo", swipeObject);
wait(200);
}
public static void swipeUpElement(AppiumDriver<MobileElement> driver, MobileElement element, int duration)
{
int topY = element.getLocation().getY();
int bottomY = topY + element.getSize().getHeight();
int centerX = element.getLocation().getX() + (element.getSize().getWidth()/2);
driver.swipe(centerX, bottomY, centerX, topY, duration);
}
但是在这两个中我都需要元素-但在页面上我找不到除 webview 之外的任何元素。
我正在使用 UiAutomator 来捕获 ID。
任何建议/链接/解决方法都会有所帮助
【问题讨论】:
标签: android testing webview automated-tests appium