0

I am unable to perform drag and drop action using below code in Android Hybrid App using Appium.

Platform : Appium with windows

Option 1

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

Option 2

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

Option 3

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

Appium version: 1.4.13 ; Android OS: 4.4.2

Error: Appium throws an error like it did not perform drag action successfully.

--- log appium server ---- info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"Did not drag successfully","status":13}

Note: I tried in both Horizontal and Vertical perspective but no luck.

2 Answers2

0

You can use instruments to record your drag and drop gesture and use the generated uiautomation scripts in JAVASCRIPT executor ..

  1. Open your instruments (sub ide of xcode)
  2. Choose your simulator with the hybrid app
  3. Choose record option in instruments
  4. Manually perform drag and drop gesture
  5. Uiautomation scripts for corresponding gesture will get generated
  6. Copy the script and use in JavaScriptexecutor and execute the code
0

I believe drag drop most of the elements will be implemented as list and the 1st element should be clicked at times before performing move actions

You can use the index of that element to move try this

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();

Replace get(0),(7) by your index no of your id's

karthick23
  • 1,313
  • 1
  • 8
  • 15