【问题标题】:Not able to do swipe operation in appium. Method is getting deprecated无法在 appium 中进行滑动操作。方法被弃用
【发布时间】:2017-03-19 13:26:05
【问题描述】:

我正在尝试使用 appium 中的 swipe(direction, duration) 方法进行滑动操作。但是刷卡方法正在被弃用。并且在控制台上出现异常

FAILED: test
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 15 milliseconds

这是我的代码

MobileElement abc = (MobileElement) driver.findElement(By.className("android.widget.FrameLayout"));
abc.swipe(SwipeElementDirection.UP, 6000);

我认为 swipe() 方法不可用。 PFA 截图供参考。

1)eclipse 屏幕截图

https://i.stack.imgur.com/PRTdw.png

2)方法不可用截图

https://i.stack.imgur.com/kzygI.png

【问题讨论】:

    标签: android appium


    【解决方案1】:
    来自驱动程序的

    swipe() 方法已在最新版本的 Appium 中被弃用。不仅swipe(),甚至tap()、pinch()、zoom()也被弃用了。

    您现在必须使用 TouchActions 来执行滑动操作。示例代码 -

    TouchAction touchAction = new TouchAction(driver);
    touchAction.press(startX, startY).moveTo(endX, endY).release().perform();
    

    【讨论】:

    • 嗨@anish你在评论中说要使用TouchAction,但你已经使用了TouchAction。当我使用 TouchAction 时,我无法滑动。 (驱动程序是 AppiumDriver
    • 我在第一行收到警告,因为“TouchAction 是原始类型。对泛型类型 TouchAction 的引用应该被参数化”,如何解决?
    猜你喜欢
    • 2015-07-24
    • 2020-08-06
    • 2015-06-22
    • 2016-05-25
    • 2015-05-13
    • 2015-07-08
    • 1970-01-01
    • 2015-11-29
    • 2020-08-17
    相关资源
    最近更新 更多