提问者:小点点

我们是否可以使用javascript executor命令进行使用Appium的Android移动测试。


我正在尝试使用Java脚本滚动命令滚动页面,同时自动化android mobile原生应用程序滚动窗口。但我收到错误消息:org.openqa.selenium.webdriverexception:尚未实现。请帮助我们:http://appium.io/get-incloved.html

你能告诉我如何在Android移动原生应用中使用Appium和Selenium Webdriver命令向下滚动吗。


共1个答案

匿名用户

此消息表示使用javascript命令还不能用于Android

我所能建议的就是更新appium,当它可用的时候,我确信他们会在某个时候实现它。

"org.openqa.selenium.WebDriverException: Not yet implemented."

这里有一个我用来触摸swipe的方法

仅在IOS上测试

public static void touchSwipe(int startX, int startY, int endX, int endY) throws WebDriverException{
    JavascriptExecutor js = (JavascriptExecutor) TestSetup.AppElements.driver;
    js.executeScript("target.frontMostApp().mainWindow().scrollViews()[0].dragInsideWithOptions({startOffset:{x:0." + startX + ", y:0." + startY + "}, endOffset:{x:0." + endX + ", y:0." + endY + "}});");
}

示例输入的滑动窗口应取决于视图所在的位置。

@Test
public void myTest() throws Exception {
    touchSwipe(75, 50, 75, 1); //Swipe downwards
}