java - 当你有多个页面要向下滚动时,如何在 Appium 上向下滚动?

标签 java selenium testing mobile appium

enter image description here

当你有多个页面时,我如何向下滚动。在第三页底部有一个链接,但是当我使用 driver.scrollTo(); 时,它会跳过并返回到第一页。

最佳答案

你可以使用 JavaScriptExecutor 来滚动 我已经创建了以下滚动方法,它在 iOS 中运行良好,但尚未针对 Android 进行测试

public static void swipe(AppiumDriver<?> driver,String sDirection, int iCount)

{
    while(iCount>0)
    {
        HashMap<String,String> swipeObject=new HashMap<String,String>();
        swipeObject.put("direction", sDirection);

        JavascriptExecutor jsDriver=(JavascriptExecutor)driver;

        jsDriver.executeScript("mobile:scroll", swipeObject);
        iCount--;

    }
}

希望对您有所帮助:)

关于java - 当你有多个页面要向下滚动时,如何在 Appium 上向下滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45317642/

相关文章:

Python Selenium 多处理

angular - 引用错误 : service is not defined

javascript - 如何在 contenteditable span 中设置插入符号位置然后发送 key ?

javascript - 如何自动测试 Chrome 扩展中的内容脚本?

java - 调用 entityManager.getTransaction() 时出现 EJBException

java - 我需要在 Jenkins 中运行什么 Windows 批处理命令才能启动脚本?

java - 如何将一个方法作为其他方法的参数传递,但使最后一个方法在其签名上具有泛型作为参数?

java - Java 代码内部基准测试

selenium - Testim.io 与 Selenium 有何不同?

c# - C# 中的 Selenium Web 驱动程序消息验证