0

我无法在使用 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}

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

4

2 回答 2

0

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

  1. 打开您的仪器(xcode 的子版本)
  2. 使用混合应用程序选择您的模拟器
  3. 在仪器中选择记录选项
  4. 手动执行拖放手势
  5. 将生成相应手势的 Uiautomation 脚本
  6. 复制脚本并在 JavaScriptexecutor 中使用并执行代码
于 2016-02-14T17:45:11.250 回答
0

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

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

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 的索引号

于 2016-02-15T11:00:39.377 回答