Not able to do long press and move from centre of 1st to 2nd element

Hi All,

I’m trying to achieve dry and drop by doing long press on first element’s centre and move to 2nd element’s centre position.

It is always failing with below reasons

Selenium::WebDriver::Error::UnknownError:
ERROR running Appium command: Cannot read property ‘element’ of undefined
# /Users/vikram/.rvm/gems/ruby-2.1.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/response.rb:52:in assert_ok' # /Users/vikram/.rvm/gems/ruby-2.1.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/response.rb:15:ininitialize’
# /Users/vikram/.rvm/gems/ruby-2.1.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/common.rb:59:in new' # /Users/vikram/.rvm/gems/ruby-2.1.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/common.rb:59:increate_response’
# /Users/vikram/.rvm/gems/ruby-2.1.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/default.rb:66:in request' # /Users/vikram/.rvm/gems/ruby-2.1.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/common.rb:40:incall’
# /Users/vikram/.rvm/gems/ruby-2.1.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/bridge.rb:640:in raw_execute' # /Users/vikram/.rvm/gems/ruby-2.1.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/bridge.rb:618:inexecute’
# /Users/vikram/.rvm/gems/ruby-2.1.1/gems/appium_lib-6.0.0/lib/appium_lib/device/device.rb:355:in touch_actions' # /Users/vikram/.rvm/gems/ruby-2.1.1/gems/appium_lib-6.0.0/lib/appium_lib/device/touch_actions.rb:120:inperform’

code —

   ele1_center = center_position text(ele1)
    ele1_center.merge(fingers: 1, duration: 3000)
    ele2_center = center_position text(ele2)
    action = Appium::TouchAction.new.long_press(ele1_center)
    action.release.perform.move_to(ele2_center)
    action.release.perform

Thanks in advance.

Regards,
Vikram

server output

2015-02-06 18:03:57:563 - info: --> POST /wd/hub/session/ef4ddd59-1899-4f80-ba7c-e3d6ade853d8/touch/perform {“actions”:[{“action”:“longPress”,“options”:{“x”:223,“y”:531.5}},{“action”:“moveTo”,“options”:{“x”:200.5,“y”:1017.5}},{“action”:“release”}]}
2015-02-06 18:03:57:563 - info: [debug] Pushing command to appium work queue: [“element:getLocation”,{}]
2015-02-06 18:03:57:566 - info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:getLocation”,“params”:{}}
2015-02-06 18:03:57:566 - info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
2015-02-06 18:03:57:567 - info: [debug] [BOOTSTRAP] [debug] Got command action: getLocation
2015-02-06 18:03:57:567 - info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:7}

2015-02-06 18:03:57:585 - error: Unhandled error: TypeError: Cannot read property ‘x’ of undefined
at null. (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/android/android-controller.js:871:29)
at next (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:801:43)
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:32:16
at exports.respond (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/common.js:28:9)
at null. (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/android/android.js:484:16)
at null. (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/android/uiautomator.js:93:9)

@VikramSilk :- I created a video with java code, May be it will help you. Have a try

@Appium_Master

Thanks for the example video but your solution is not working in my case.

  1. Application has 2 rows , you can consider similar to gmail mails
  2. first row I need to do long press , before starting drag and drop on another element

below 2 approaches are failed

action1 = Appium::TouchAction.new.long_press(ele1_center).move_to(ele2_center).release.perform

action1 = Appium::TouchAction.new.long_press(ele1_center).perform.wait(1000).move_to(ele2_center).release.perform

server log as below

UiSelector coerce type: java.lang.Class arg: “android.widget.TextView”
2015-02-09 14:35:25:188 - info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: “android.widget.TextView”
2015-02-09 14:35:25:188 - info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: “perspiciatis”
2015-02-09 14:35:25:188 - info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.TextView, RESOURCE_ID=perspiciatis]

2015-02-09 14:35:25:227 - info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.TextView, CONTAINS_DESCRIPTION=perspiciatis]

2015-02-09 14:35:25:476 - info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CONTAINS_TEXT=perspiciatis, CLASS=android.widget.TextView]

2015-02-09 14:35:25:537 - info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:{“ELEMENT”:“41”},“status”:0}

2015-02-09 14:35:25:537 - info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“41”},“sessionId”:“0416df31-e602-4c05-ac1e-9fd8541f013a”}
2015-02-09 14:35:25:538 - info: <-- POST /wd/hub/session/0416df31-e602-4c05-ac1e-9fd8541f013a/element 200 365.555 ms - 88 {“status”:0,“value”:{“ELEMENT”:“41”},“sessionId”:“0416df31-e602-4c05-ac1e-9fd8541f013a”}

2015-02-09 14:35:25:540 - info: --> GET /wd/hub/session/0416df31-e602-4c05-ac1e-9fd8541f013a/element/41/location {}
2015-02-09 14:35:25:541 - info: [debug] Pushing command to appium work queue: [“element:getLocation”,{“elementId”:“41”}]
2015-02-09 14:35:25:544 - info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:getLocation”,“params”:{“elementId”:“41”}}
2015-02-09 14:35:25:546 - info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
2015-02-09 14:35:25:548 - info: [debug] [BOOTSTRAP] [debug] Got command action: getLocation

2015-02-09 14:35:25:589 - info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:{“y”:986,“x”:170},“status”:0}
2015-02-09 14:35:25:589 - info: [debug] Responding to client with success: {“status”:0,“value”:{“y”:986,“x”:170},“sessionId”:“0416df31-e602-4c05-ac1e-9fd8541f013a”}
2015-02-09 14:35:25:590 - info: <-- GET /wd/hub/session/0416df31-e602-4c05-ac1e-9fd8541f013a/element/41/location 200 50.158 ms - 89 {“status”:0,“value”:{“y”:986,“x”:170},“sessionId”:“0416df31-e602-4c05-ac1e-9fd8541f013a”}
2015-02-09 14:35:25:593 - info: --> GET /wd/hub/session/0416df31-e602-4c05-ac1e-9fd8541f013a/element/41/size {}
2015-02-09 14:35:25:595 - info: [debug] Pushing command to appium work queue: [“element:getSize”,{“elementId”:“41”}]
2015-02-09 14:35:25:597 - info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:getSize”,“params”:{“elementId”:“41”}}
2015-02-09 14:35:25:598 - info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
2015-02-09 14:35:25:598 - info: [debug] [BOOTSTRAP] [debug] Got command action: getSize

2015-02-09 14:35:25:658 - info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:{“height”:63,“width”:229},“status”:0}

2015-02-09 14:35:25:663 - info: [debug] Responding to client with success: {“status”:0,“value”:{“height”:63,“width”:229},“sessionId”:“0416df31-e602-4c05-ac1e-9fd8541f013a”}
2015-02-09 14:35:25:664 - info: <-- GET /wd/hub/session/0416df31-e602-4c05-ac1e-9fd8541f013a/element/41/size 200 71.450 ms - 97 {“status”:0,“value”:{“height”:63,“width”:229},“sessionId”:“0416df31-e602-4c05-ac1e-9fd8541f013a”}

2015-02-09 14:35:25:698 - info: --> POST /wd/hub/session/0416df31-e602-4c05-ac1e-9fd8541f013a/touch/perform {“actions”:[{“action”:“longPress”,“options”:{“x”:208,“y”:531.5}},{“action”:“moveTo”,“options”:{“x”:284.5,“y”:1017.5}},{“action”:“release”}]}
2015-02-09 14:35:25:700 - info: [debug] Pushing command to appium work queue: [“element:getLocation”,{}]

2015-02-09 14:35:25:756 - info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:getLocation”,“params”:{}}
2015-02-09 14:35:25:785 - info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
2015-02-09 14:35:25:785 - info: [debug] [BOOTSTRAP] [debug] Got command action: getLocation
2015-02-09 14:35:25:785 - info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:7}

2015-02-09 14:35:25:770 - error: Unhandled error: TypeError: Cannot read property ‘x’ of undefined
at null. (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/android/android-controller.js:871:29)
at next (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:801:43)
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:32:16
at exports.respond (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/common.js:28:9)
at null. (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/android/android.js:484:16)
at null. (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/android/uiautomator.js:93:9)
at Socket.emit (events.js:95:17)
at Socket. (stream_readable.js:765:14)
at Socket.emit (events.js:92:17)
at emitReadable
(_stream_readable.js:427:10) context: [POST /wd/hub/session {“desiredCapabilities”:{“platformName”:“Android”,“appWaitActivity”:".activity.WLStartViewFragmentActivity",“appPackage”:“com.wunderkinder.wunderlistandroid”,“appium-version”:“1.3.4”,“deviceName”:"Andr]