I met an issue that I can found the 'Add' button element but after click or tap, nothing happened.
I used the code below to locate the Add button and click it
‘… WebElement addbtn = this.driver.findElementByXPath(".//*[@content-desc='Add']");
addbtn.click();
…’
Or
‘… WebElement addbtn = this.driver.findElementByXPath(".//*[@content-desc='Add']");
TouchAction Action = new TouchAction((MobileDriver) driver);
Action.tap(addbtn).perform();
…’
Neither method worked after click Add, and in the Appium log it said,’
2016-11-30 09:40:09:900 - info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":".//*[@content-desc='Add']","context":"","multiple":false}]
2016-11-30 09:40:09:914 - info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":".//*[@content-desc='Add']","context":"","multiple":false}}
2016-11-30 09:40:09:915 - info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
2016-11-30 09:40:09:916 - info: [debug] [BOOTSTRAP] [debug] Got command action: find
2016-11-30 09:40:09:916 - info: [debug] [BOOTSTRAP] [debug] Finding .//*[@content-desc='Add'] using XPATH with the contextId: multiple: false
2016-11-30 09:40:09:968 - info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.Button, INSTANCE=1]
2016-11-30 09:40:09:987 - info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"ELEMENT":"20"}}
2016-11-30 09:40:09:990 - info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"20"},"sessionId":"0011de81-da81-491e-8129-25a7f3213588"}
2016-11-30 09:40:09:991 - info: <-- POST /wd/hub/session/0011de81-da81-491e-8129-25a7f3213588/element 200 91.403 ms - 88 {"status":0,"value":{"ELEMENT":"20"},"sessionId":"0011de81-da81-491e-8129-25a7f3213588"}
2016-11-30 09:40:09:996 - info: --> POST /wd/hub/session/0011de81-da81-491e-8129-25a7f3213588/touch/perform {"actions":[{"action":"tap","options":{"element":"20"}}]}
2016-11-30 09:40:09:998 - info: [debug] Pushing command to appium work queue: ["element:getLocation",{"elementId":"20"}]
2016-11-30 09:40:10:006 - info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:getLocation","params":{"elementId":"20"}}
2016-11-30 09:40:10:010 - info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
2016-11-30 09:40:10:010 - info: [debug] [BOOTSTRAP] [debug] Got command action: getLocation
2016-11-30 09:40:10:026 - info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"x":1456,"y":2368}}
2016-11-30 09:40:10:029 - info: [debug] Pushing command to appium work queue: ["element:getSize",{"elementId":"20"}]
2016-11-30 09:40:10:033 - info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:getSize","params":{"elementId":"20"}}
2016-11-30 09:40:10:036 - info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
2016-11-30 09:40:10:036 - info: [debug] [BOOTSTRAP] [debug] Got command action: getSize
2016-11-30 09:40:10:072 - info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"width":204,"height":192}}
2016-11-30 09:40:10:074 - info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"20","x":1558,"y":2464}]
2016-11-30 09:40:10:083 - info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"20","x":1558,"y":2464}}
2016-11-30 09:40:10:083 - info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
2016-11-30 09:40:10:083 - info: [debug] [BOOTSTRAP] [debug] Got command action: click
2016-11-30 09:40:13:262 - info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
2016-11-30 09:40:13:266 - info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"0011de81-da81-491e-8129-25a7f3213588"}
2016-11-30 09:40:13:267 - info: <-- POST /wd/hub/session/0011de81-da81-491e-8129-25a7f3213588/touch/perform 200 3271.188 ms - 76 {"status":0,"value":true,"sessionId":"0011de81-da81-491e-8129-25a7f3213588"}
...'
And the UI element from getSource() can be found in the attachment UI.txtUI.txt (12.1 KB)
Also attached the snapshot of the uiautomatorviewer