【问题标题】:Unable to perform Drag and Drop action in Android using Appium无法使用 Appium 在 Android 中执行拖放操作
【发布时间】:2016-05-25 11:51:07
【问题描述】:

我无法在使用 Appium 的 Android Hybrid App 中使用以下代码执行拖放操作。

平台:带窗口的 Appium

选项 1

new TouchAction(driver).longPress(ele1).moveTo(ele2).release.perform();

选项 2

new TouchAction(driver).longPress(ele1).moveTo(ele2, 252, 180).release.perform();

选项 3

new TouchAction(driver).longPress(ele1, 252, 152).moveTo(ele2, 252, 180).release.perform();

Appium 版本:1.4.13;安卓操作系统:4.4.2

错误:Appium 抛出一个错误,就像它没有成功执行拖动操作一样。

--- log appium server ---- info: [debug] [BOOTSTRAP] [debug] 返回结果:{"value":"Did not drag successfully","status":13}

注意:我尝试了水平和垂直透视,但没有运气。

【问题讨论】:

    标签: android appium appium-ios


    【解决方案1】:

    您可以使用工具来记录您的拖放手势,并在 JAVASCRIPT 执行器中使用生成的 uiautomation 脚本 ..

    1. 打开您的仪器(xcode 的子 ide)
    2. 使用混合应用选择您的模拟器
    3. 在仪器中选择记录选项
    4. 手动执行拖放手势
    5. 将生成相应手势的 Uiautomation 脚本
    6. 复制脚本并在JavaScriptexecutor中使用并执行代码

    【讨论】:

    • 您好,感谢您的 cmets。我在 Windows 上使用 appium(android)。你能解释一下如何在windows中完成吗?谢谢 Vinoth
    • @VinothVino 这似乎也值得在问题中提及
    • 但是 testroid 不是免费的
    • 你能尝试在新的 TouchAction(driver).longPress(ele1).wait(somewait).moveTo(ele2).release.perform(); 等动作之间稍等片刻吗?
    • 我已经尝试过等待。但是appium会抛出等待错误。等待问题已经存在。
    【解决方案2】:

    我相信拖放大部分元素将被实现为列表,并且在执行移动操作之前有时应该单击第一个元素

    您可以使用该元素的索引来移动 试试这个

    driver.findElements(By.id("your identifier")).get(0).click();
    new TouchAction((MobileDriver)driver).longPress(driver.findElements(By.id("your identifier")).get(0)).moveTo(driver.findElements(By.id("your identifier")).get(7)).release().perform();
    

    将 get(0),(7) 替换为您的 id 的索引号

    【讨论】:

    • @Karthick 我也尝试过这种可能性。我遇到了同样的问题“成功完成拖动”
    • 你能分享两个元素的 uiautomator 视图 sn-p
    • 对不起卡西克。我无法发布 sn-ps,因为我们这里有限制。除了这个,你还需要我什么?
    • 我不能在没有看到他们的情况下发表更多评论
    猜你喜欢
    • 1970-01-01
    • 2020-07-27
    • 2018-02-14
    • 1970-01-01
    • 1970-01-01
    • 2018-08-04
    • 1970-01-01
    • 1970-01-01
    • 2010-11-05
    相关资源
    最近更新 更多