So I’ve done more digging and if I’m understanding the logs correctly I think I see what is happening.
When Appium receives the elements from the device it’s getting different xpaths each time.
Notice these two logs. One shows it pushing the command to xPath(’/0/0/13’) and the other (’/0/0/9’). One of these actually clicked the button I wanted and one didn’t.
Wrong Button clicked
{“status”:0,“value”:{“UIAApplication”:{"@":{“name”:“Xxxxxx”,“label”:“Xxxxxx”,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0",“x”:0,“y”:0,“width”:320,“height”:568},">":[{“UIAWindow”:{"@":{“name”:null,“label”:null,“value”:null,“dom”:null,“enabled”:true,
info: [debug] Pushing command to appium work queue: “au.getElementByIndexPath(’/0/0/9’)”
Correct Button clicked
{“status”:0,“value”:{“UIAApplication”:{"@":{“name”:“Xxxxxx”,“label”:“Xxxxxx”,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0",“x”:0,“y”:0,“width”:320,“height”:568},">":[{“UIAWindow”:{"@":{“name”:null,“label”:null,“value”:null,“dom”:null,“enabled”:true,
info: [debug] Pushing command to appium work queue: “au.getElementByIndexPath(’/0/0/13’)”
It’s even more clear here when it’s receiving the elements. This field is labeled and you see the paths are different on two different executions of the test script.
Execution 1
[]}},{“UIASearchBar”:{"@":{“name”:“Where would you like to eat? “,“label”:“Where would you like to eat? “,“value”:“Where would you like to eat?”,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:”/0/0/11”,“x”:9,“y”:72,“width”:264,“height”:28},”>”:[]}},
Execution 2
[]}},{“UIASearchBar”:{"@":{“name”:“Where would you like to eat? “,“label”:“Where would you like to eat? “,“value”:“Where would you like to eat?”,”dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:”/0/0/16”,“x”:9,“y”:72,“width”:264,“height”:28},”>”:[]}},
I don’t see this type of behavior when getting elements on other screens where I don’t have this issue.
Execution 1
{“UIAStaticText”:{"@":{“name”:“and enter your phone number”,“label”:“and enter your phone number”,“value”:“and enter your phone number”,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/1/1",“x”:70,“y”:92,“width”:181,“height”:21},">":[]}},{“UIAButton”:
Execution 2
{“UIAStaticText”:{"@":{“name”:“and enter your phone number”,“label”:“and enter your phone number”,“value”:“and enter your phone number”,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/1/1",“x”:70,“y”:92,“width”:181,“height”:21},">":[]}},{“UIAButton”:
A little bit about this screen… This screen has a search bar at the top and a map (google api) below where the users can search for locations. Is there something about this type of screen that I need to interact with it differently?
Thanks!
Matt