I dont know if it’s a documentation issue , or my misunderstanding of the touchAction’s chaining idea , but it doesn’t work for me as expected (by me at least :))
The requirement : touch on several places on the screen , and then release the “fingers”
for example , if you are touching some num pad , on “1 , 2” then once you release the “fingers” you will see 12 on the view …
my impl :
String text = "123";
TouchAction touchAction = new TouchAction(driver);
for (char c : text.toCharArray()){
MyPoint myPoint = (MyPoint)authMatrix.get(String.valueOf(c));
touchAction = touchAction.press((int)(initialX + paddingW * myPoint.X),
(int)(initialY + paddingH * myPoint.Y)).waitAction(100);
}
touchAction.release().perform();
the initialX/Y and the paddings are calculated according to the element location / size.
I’ve tried to execute the code above while
`text = "1"`
in this case there is no chaining
Appium logs :
info: --> POST /wd/hub/session/8c2608d1-bc78-4d88-b3a0-f6420bd595b7/touch/perform {"actions":[{"action":"press","options":{"x":135,"y":1216}},{"action":"wait","options":{"ms":100}},{"action":"release","options":{}}]}
info: [debug] Pushing command to appium work queue: ["element:touchDown",{"x":135,"y":1216}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:touchDown","params":{"x":135,"y":1216}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: touchDown
info: [debug] [BOOTSTRAP] [debug] Display bounds: [0,0][1080,1776]
info: [debug] [BOOTSTRAP] [debug] Performing TouchDown using element? false x: 135, y: 1216
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] Pushing command to appium work queue: ["element:touchUp",{"x":135,"y":1216}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:touchUp","params":{"x":135,"y":1216}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: touchUp
info: [debug] [BOOTSTRAP] [debug] Display bounds: [0,0][1080,1776]
info: [debug] [BOOTSTRAP] [debug] Performing TouchUp using element? false x: 135, y: 1216
Then I’ve tried to run it while
text = "2"
no chaining as well and the logs :
info: --> POST /wd/hub/session/8c2608d1-bc78-4d88-b3a0-f6420bd595b7/touch/perform {"actions":[{"action":"press","options":{"x":405,"y":1216}},{"action":"wait","options":{"ms":100}},{"action":"release","options":{}}]}
info: [debug] Pushing command to appium work queue: ["element:touchDown",{"x":405,"y":1216}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:touchDown","params":{"x":405,"y":1216}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: touchDown
info: [debug] [BOOTSTRAP] [debug] Display bounds: [0,0][1080,1776]
info: [debug] [BOOTSTRAP] [debug] Performing TouchDown using element? false x: 405, y: 1216
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] Pushing command to appium work queue: ["element:touchUp",{"x":405,"y":1216}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:touchUp","params":{"x":405,"y":1216}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: touchUp
info: [debug] [BOOTSTRAP] [debug] Display bounds: [0,0][1080,1776]
info: [debug] [BOOTSTRAP] [debug] Performing TouchUp using element? false x: 405, y: 1216
Finally I’ve tried to execute with chaining while
text = "12"
there is a chaining on the touchaction object, and the logs are :
info: --> POST /wd/hub/session/8c2608d1-bc78-4d88-b3a0-f6420bd595b7/touch/perform {"actions":[{"action":"press","options":{"x":135,"y":1216}},{"action":"wait","options":{"ms":100}},{"action":"press","options":{"x":405,"y":1216}},{"action":"wait","options":{"ms":100}},{"action":"release","options":{}}]}
info: [debug] Pushing command to appium work queue: ["element:touchDown",{"x":135,"y":1216}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:touchDown","params":{"x":135,"y":1216}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: touchDown
info: [debug] [BOOTSTRAP] [debug] Display bounds: [0,0][1080,1776]
info: [debug] [BOOTSTRAP] [debug] Performing TouchDown using element? false x: 135, y: 1216
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] Pushing command to appium work queue: ["element:touchDown",{"x":540,"y":2432}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:touchDown","params":{"x":540,"y":2432}}
Clearly you can see that the first touch is correct (first loop iteration) but the second loop’s iteration - the touch chaining is actually is a concatenation of the first touch and the second potential one (the x coordinate 540 is the result of first x = 135 and the second x = 405 …)
Could you please explain what I’m doing wrong / misunderstanding ?
I know that I can create a touchaction instance within the for loop and perform the touch per each loop’s iteration , but then I’m not using the chaining “idea” …