我们可以使用appium将javascript执行器命令用于Android移动测试吗

Can we use javascript executor commands for Android mobile testing using appium.

本文关键字:用于 命令 Android 移动 测试 执行 可以使 appium javascript 我们      更新时间:2023-09-26

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

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

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

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

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

这是我用来触摸滑动的一种方法

仅在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
}