I have used below code to press long press. It is working and thrown exception.
webElement = driver.findElementByAccessibilityId(“Sign Up Now!”);
int x = webElement.getLocation().getX();
int y = webElement.getLocation().getY();
System.out.println("x:" + x);
System.out.println("y:" + y);
TouchAction tAction = new TouchAction(driver);
tAction.longPress(webElement,x,y).perform();
Error log:
org.openqa.selenium.WebDriverException: An error occurred while executing user supplied JavaScript. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.36 seconds
Build info: version: ‘2.45.0’, revision: ‘5017cb8e7ca8e37638dc3091b2440b90a1d8686f’, time: ‘2015-02-27 09:10:26’
System info: host: ‘CSCINDAF026517.local’, ip: ‘10.31.24.12’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.10.5’, java.version: ‘1.8.0_51’
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities [{networkConnectionEnabled=false, warnings={}, bundleId=com.justforu.client.ent, databaseEnabled=false, deviceName=6356ef8679bf3f54b6bf159273598bbe5d68012e, platform=MAC, desired={newCommandTimeout=9999, platformVersion=9.2.1, bundleId=com.justforu.client.ent, udid=6356ef8679bf3f54b6bf159273598bbe5d68012e, platformName=iOS, deviceName=6356ef8679bf3f54b6bf159273598bbe5d68012e, applicationName=6356ef8679bf3f54b6bf159273598bbe5d68012e}, newCommandTimeout=9999, platformVersion=9.2.1, webStorageEnabled=false, locationContextEnabled=false, browserName=iOS, takesScreenshot=true, javascriptEnabled=true, udid=6356ef8679bf3f54b6bf159273598bbe5d68012e, platformName=iOS, applicationName=6356ef8679bf3f54b6bf159273598bbe5d68012e}]
Session ID: 4bd596d0-f372-4f15-a359-59d0784016e7
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)
at io.appium.java_client.AppiumDriver.performTouchAction(AppiumDriver.java:304)
at io.appium.java_client.TouchAction.perform(TouchAction.java:253
appium log:
info: --> POST /wd/hub/session/4bd596d0-f372-4f15-a359-59d0784016e7/element {“using”:“accessibility id”,“value”:“Sign Up Now!”}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: “au.getElementByAccessibilityId(‘Sign Up Now!’)”
info: [debug] Sending command to instruments: au.getElementByAccessibilityId(‘Sign Up Now!’)
info: [debug] [INST] 2016-02-01 17:04:21 +0000 Debug: Got new command 4 from instruments: au.getElementByAccessibilityId(‘Sign Up Now!’)
info: [debug] [INST] 2016-02-01 17:04:21 +0000 Debug: evaluating au.getElementByAccessibilityId(‘Sign Up Now!’)
info: [debug] [INST] 2016-02-01 17:04:21 +0000 Debug: evaluation finished
info: [debug] [INST] 2016-02-01 17:04:21 +0000 Debug: Lookup returned [object UIAButton] with the name “Sign Up Now!” (id: 1).
info: [debug] [INST] 2016-02-01 17:04:21 +0000 Debug: responding with:
info: [debug] [INST] 2016-02-01 17:04:21 +0000 Debug: Running system command #5: /usr/local/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:0,“value”:{“ELEMENT”:“1”}}…
info: [debug] Socket data received (38 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:0,“value”:{“ELEMENT”:“1”}}
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“1”},“sessionId”:“4bd596d0-f372-4f15-a359-59d0784016e7”}
info: <-- POST /wd/hub/session/4bd596d0-f372-4f15-a359-59d0784016e7/element 200 1036.538 ms - 87 {“status”:0,“value”:{“ELEMENT”:“1”},“sessionId”:“4bd596d0-f372-4f15-a359-59d0784016e7”}
info: --> GET /wd/hub/session/4bd596d0-f372-4f15-a359-59d0784016e7/element/1/location {}
info: [debug] Pushing command to appium work queue: “au.getElement(‘1’).getElementLocation()”
info: [debug] Sending command to instruments: au.getElement(‘1’).getElementLocation()
info: [debug] [INST] 2016-02-01 17:04:22 +0000 Debug: Got new command 5 from instruments: au.getElement(‘1’).getElementLocation()
info: [debug] [INST] 2016-02-01 17:04:22 +0000 Debug: evaluating au.getElement(‘1’).getElementLocation()
info: [debug] [INST] 2016-02-01 17:04:22 +0000 Debug: evaluation finished
info: [debug] [INST] 2016-02-01 17:04:22 +0000 Debug: responding with:
info: [debug] [INST] 2016-02-01 17:04:22 +0000 Debug: Running system command #6: /usr/local/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:0,“value”:{“x”:58.59375,“y”:516.3125}}…
info: [debug] Socket data received (50 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:0,“value”:{“x”:58.59375,“y”:516.3125}}
info: [debug] Responding to client with success: {“status”:0,“value”:{“x”:58.59375,“y”:516.3125},“sessionId”:“4bd596d0-f372-4f15-a359-59d0784016e7”}
info: <-- GET /wd/hub/session/4bd596d0-f372-4f15-a359-59d0784016e7/element/1/location 200 1020.148 ms - 99 {“status”:0,“value”:{“x”:58.59375,“y”:516.3125},“sessionId”:“4bd596d0-f372-4f15-a359-59d0784016e7”}
info: --> GET /wd/hub/session/4bd596d0-f372-4f15-a359-59d0784016e7/element/1/location {}
info: [debug] Pushing command to appium work queue: “au.getElement(‘1’).getElementLocation()”
info: [debug] Sending command to instruments: au.getElement(‘1’).getElementLocation()
info: [debug] [INST] 2016-02-01 17:04:23 +0000 Debug: Got new command 6 from instruments: au.getElement(‘1’).getElementLocation()
info: [debug] [INST] 2016-02-01 17:04:23 +0000 Debug: evaluating au.getElement(‘1’).getElementLocation()
info: [debug] [INST] 2016-02-01 17:04:23 +0000 Debug: evaluation finished
info: [debug] [INST] 2016-02-01 17:04:23 +0000 Debug: responding with:
info: [debug] [INST] 2016-02-01 17:04:23 +0000 Debug: Running system command #7: /usr/local/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:0,“value”:{“x”:58.59375,“y”:516.3125}}…
info: [debug] Socket data received (50 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:0,“value”:{“x”:58.59375,“y”:516.3125}}
info: [debug] Responding to client with success: {“status”:0,“value”:{“x”:58.59375,“y”:516.3125},“sessionId”:“4bd596d0-f372-4f15-a359-59d0784016e7”}
info: <-- GET /wd/hub/session/4bd596d0-f372-4f15-a359-59d0784016e7/element/1/location 200 949.786 ms - 99 {“status”:0,“value”:{“x”:58.59375,“y”:516.3125},“sessionId”:“4bd596d0-f372-4f15-a359-59d0784016e7”}
info: --> POST /wd/hub/session/4bd596d0-f372-4f15-a359-59d0784016e7/touch/perform {“actions”:[{“action”:“longPress”,“options”:{“element”:“1”,“x”:58,“y”:516}}]}
info: [debug] Pushing command to appium work queue: “au.getElement(‘1’).rect()”
info: [debug] Sending command to instruments: au.getElement(‘1’).rect()
info: [debug] [INST] 2016-02-01 17:04:24 +0000 Debug: Got new command 7 from instruments: au.getElement(‘1’).rect()
info: [debug] [INST] 2016-02-01 17:04:24 +0000 Debug: evaluating au.getElement(‘1’).rect()
info: [debug] [INST] 2016-02-01 17:04:24 +0000 Debug: evaluation finished
info: [debug] [INST] 2016-02-01 17:04:24 +0000 Debug: responding with:
info: [debug] [INST] 2016-02-01 17:04:24 +0000 Debug: Running system command #8: /usr/local/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:0,“value”:{“origin”:{“x”:58.59375,“y”:516.3125},“size”:{“width”:257.8125,“height”:53.90625}}}…
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.4.16”,“revision”:“ae6877eff263066b26328d457bd285c0cc62430d”},“isShuttingDown”:false},“sessionId”:“4bd596d0-f372-4f15-a359-59d0784016e7”}
info: <-- GET /wd/hub/status 200 1.227 ms - 179 {“status”:0,“value”:{“build”:{“version”:“1.4.16”,“revision”:“ae6877eff263066b26328d457bd285c0cc62430d”},“isShuttingDown”:false},“sessionId”:“4bd596d0-f372-4f15-a359-59d0784016e7”}
info: [debug] Socket data received (105 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:0,“value”:{“origin”:{“x”:58.59375,“y”:516.3125},“size”:{“width”:257.8125,“height”:53.90625}}}
info: [debug] Pushing command to appium work queue: “target.touch([{“touch”:[{“x”:116.59375,“y”:1032.3125}],“time”:0.2}])”
info: [debug] Sending command to instruments: target.touch([{“touch”:[{“x”:116.59375,“y”:1032.3125}],“time”:0.2}])
info: [debug] [INST] 2016-02-01 17:04:25 +0000 Debug: Got new command 8 from instruments: target.touch([{“touch”:[{“x”:116.59375,“y”:1032.3125}],“time”:0.2}])
info: [debug] [INST] 2016-02-01 17:04:25 +0000 Debug: evaluating target.touch([{“touch”:[{“x”:116.59375,“y”:1032.3125}],“time”:0.2}])
info: [debug] [INST] 2016-02-01 17:04:25 +0000 Debug: target.touch(__NSCFArray)
info: [debug] [INST] 2016-02-01 17:04:25 +0000 Debug: point is not within the bounds of the screen
info: [debug] Socket data received (70 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:17,“value”:“point is not within the bounds of the screen”}
info: [debug] Responding to client with error: {“status”:17,“value”:{“message”:“An error occurred while executing user supplied JavaScript.”,“origValue”:“point is not within the bounds of the screen”},“sessionId”:“4bd596d0-f372-4f15-a359-59d0784016e7”}
info: <-- POST /wd/hub/session/4bd596d0-f372-4f15-a359-59d0784016e7/touch/perform 500 2348.785 ms - 205
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.4.16”,“revision”:“ae6877eff263066b26328d457bd285c0cc62430d”},“isShuttingDown”:false},“sessionId”:“4bd596d0-f372-4f15-a359-59d0784016e7”}
info: <-- GET /wd/hub/status 200 2.773 ms - 179 {“status”:0,“value”:{“build”:{“version”:“1.4.16”,“revision”:“ae6877eff263066b26328d457bd285c0cc62430d”},“isShuttingDown”:false},“sessionId”:“4bd596d0-f372-4f15-a359-59d0784016e7”}
info: [debug] [INST] 2016-02-01 17:04:25 +0000 Error: VerboseError: point is not within the bounds of the screen
info: [debug] [INST] 2016-02-01 17:04:25 +0000 Error: Error during eval: touch@[native code]
eval code
eval@[native code]
startProcessing@file:///usr/local/lib/node_modules/appium/B4FA4DCB-6CD0-4E49-B787-94B237FFE6FF/bootstrap-8c66b08aef28474d.js:2710:30
bootstrap@file:///usr/local/lib/node_modules/appium/B4FA4DCB-6CD0-4E49-B787-94B237FFE6FF/bootstrap-8c66b08aef28474d.js:2778:31
global code@file:///usr/local/lib/node_modules/appium/B4FA4DCB-6CD0-4E49-B787-94B237FFE6FF/bootstrap-8c66b08aef28474d.js:2787:10
info: [debug] [INST] 2016-02-01 17:04:26 +0000 Debug: responding with:
info: [debug] [INST] 2016-02-01 17:04:26 +0000 Debug: Running system command #9: /usr/local/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:17,“value”:“point is not within the bounds of the screen”}…
info: --> GET /wd/hub/status {}
Request anyone support in this…