I am new to the automation testing (Selenium Grid and appium) in mobile devices (android) and I am facing a problem with longPress action in a physical android device (Samsung Galaxy S5). When i call longPress(WebElement el, int x, int y) it seems that appium does not respect the coordinates i give as parameters and keeps longpressing at the center of an TextView element. In Appium logs, i see that it gets my coordinates but when it performs longPress action it is at the center of the element.
Here are the logs from appium instance:
info: --> POST /wd/hub/session/8db9e619-aabb-4a55-81a8-f7a35e342b4c/touch/perform {"actions":[{"action":"longPress","options":{"element":"15","x":100,"y":0}}]}
info: [debug] Pushing command to appium work queue: ["element:getLocation",{"elementId":"15"}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:getLocation","params":{"elementId":"15"}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getLocation
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"x":102,"y":527}}
info: [debug] Pushing command to appium work queue: ["element:getSize",{"elementId":"15"}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:getSize","params":{"elementId":"15"}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getSize
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"width":876,"height":124}}
info: [debug] Pushing command to appium work queue: ["element:touchLongClick",{"elementId":"15","x":202,"y":527,"duration":1000}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:touchLongClick","params":{"elementId":"15","x":202,"y":527,"duration":1000}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: touchLongClick
info: [debug] [BOOTSTRAP] [debug] Performing TouchLongClick using element? true x: 540, y: 589, duration: 1000
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.13","revision":"c75d8adcb66a75818a542fe1891a34260c21f76a"}},"sessionId":"8db9e619-aabb-4a55-81a8-f7a35e342b4c"}
info: <-- GET /wd/hub/status 200 0.698 ms - 156 {"status":0,"value":{"build":{"version":"1.4.13","revision":"c75d8adcb66a75818a542fe1891a34260c21f76a"}},"sessionId":"8db9e619-aabb-4a55-81a8-f7a35e342b4c"}
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
Appium version: 1.4.13.1
java-client-3.2.0
Any ideas? It seems that no one else has faced this problem because I cannot find anything related in google searches. Thanks!
EDIT: code is as follows
public void act_enterSubscriberClearedInput(String subscriber) {
appiumcontroller().tap(subscriberUIElement);
appiumcontroller().longPress(subscriberUIElement, 100, 0);
appiumcontroller().sendAndroidKeyEvent(AndroidKeyEvent.DEL);
appiumcontroller().sendKeys(subscriberUIElement, subscriber);
appiumcontroller().tap(BTN_OK);
}
public MobileController longPress(String locator, int x, int y) {
this.performTouchAction(getTouchAction().longPress(waitForMobileElement(Constants.VISIBILITY.get(), locator, appiumDriver),x,y));
return this;
}