【问题标题】:Unable to scroll android native app with appium using java client 7.0无法使用 java 客户端 7.0 滚动带有 appium 的 android 本机应用程序
【发布时间】:2019-12-10 00:42:23
【问题描述】:

我无法使用 Appium 垂直滚动 android 应用程序。 我正在使用 java-client 7.0.0 API。 Action.press 不工作

(new TouchAction(driver))
  .press({x: 600, y: 2408})
  .moveTo({x: 348: y: 615})
  .release()
  .perform()

【问题讨论】:

    标签: java selenium-webdriver appium appium-android


    【解决方案1】:

    尝试使用以下示例:

    /**
     * This method scrolls based upon the passed parameters
     * @author Bill Hileman
     * @param int startx - the starting x position
     * @param int starty - the starting y position
     * @param int endx - the ending x position
     * @param int endy - the ending y position
     */
    @SuppressWarnings("rawtypes")
    public void scroll(int startx, int starty, int endx, int endy) {
    
        TouchAction touchAction = new TouchAction(driver);
    
        touchAction.longPress(PointOption.point(startx, starty))
                   .moveTo(PointOption.point(endx, endy))
                   .release()
                   .perform();
    
    }
    

    【讨论】:

    • 您好 Bill Hileman,感谢您的解决方案它对我有用。我正在尝试使用相同的代码滚动应用程序的中间部分(页眉和页脚除外)。它不适合那个。你能提供解决方案吗?提前致谢。
    • 根据您的示例,您正试图从屏幕右下角的某个位置滚动到屏幕的左上角?通常垂直和水平滚动保持 x 或 y 坐标相同,只改变另一个。你的意思是做对角线滑动吗?我通常会获取屏幕尺寸并确定百分比,即对于水平滚动,我选择中点 x 并将 y 设置为 20% 到 80%,是否遵循?
    • 您能否将其标记为已接受的答案?很高兴我能提供帮助,感谢您让我知道。
    猜你喜欢
    • 2019-01-03
    • 2015-02-08
    • 2019-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-26
    • 2018-01-26
    • 2020-12-01
    相关资源
    最近更新 更多