【问题标题】:Tap deprecated in Appium hybrid app在 Appium 混合应用程序中不推荐使用 Tap
【发布时间】:2018-08-03 08:20:43
【问题描述】:

我对 Appium 中已弃用的 tap 有疑问,因为 eclipse 表示不推荐使用带有坐标的“tap”。我用:

TouchAction touchAction=new TouchAction(driver);
TouchAction perform = touchAction.tap(524, 1735).perform();

点击位置坐标,找不到新的“带坐标点击”功能

【问题讨论】:

  • 使用tap + coordinates 的替代方法是搜索元素并使用click() 方法。
  • 该应用程序是用 PhoneGap 编写的,并且无法找到元素,因为它们是视图中的视图,并且它们没有唯一的 id 或其他东西。我尝试使用 appium 检查器期待 xpath,但路径不正确或找不到。所以唯一的选择是使用我想点击的按钮的坐标(点击)

标签: java appium appium-android


【解决方案1】:

请查看最新的 TouchAction 类: https://appium.github.io/java-client/io/appium/java_client/TouchAction.html

点击坐标你可以这样做:

new TouchAction(localdriver).tap(point(xPoint, yPoint)).perform();

【讨论】:

    【解决方案2】:

    已弃用的点击/按下功能的替代方法是“长按”功能。这是函数:

    public T longPress(LongPressOptions longPressOptions) {
        ActionParameter action = new ActionParameter("longPress", longPressOptions);
        parameterBuilder.add(action);
        //noinspection unchecked
        return (T) this;
    }
    

    欲了解更多信息,请参阅:https://github.com/appium/java-client/blob/master/src/main/java/io/appium/java_client/TouchAction.java

    【讨论】:

    • 我尝试了之前的两种方式,使用 new TouchAction(driver).tap(524, 1735).perform(); new TouchAction((MobileDriver)driver).press(524,1735).waitAction().release().perform();但是对于“press”和“tap”仍然是方法 tap(x,y) / press(x,y) 被弃用....
    • 你说得对,press 似乎也被弃用了。从来源我可以看到他们有另一种选择:@deprecated use {@link #longPress(LongPressOptions)} instead
    • 是的,我在@deprecated 使用时看到了这一点,但我不想用已弃用的功能来做,但看起来,他们不推荐按坐标按/制表符,我将不推荐使用功能
    猜你喜欢
    • 2015-12-20
    • 2014-09-25
    • 2015-05-15
    • 1970-01-01
    • 2018-08-10
    • 1970-01-01
    • 1970-01-01
    • 2018-11-12
    • 2015-04-26
    相关资源
    最近更新 更多