appium: xpath selector doesn't work if search context is an element (not a driver)
driver.find_element(:xpath, '//UIATableView[1]')
Appium log:
debug: Appium request initiated at /wd/hub/session/43dc50b4-a81b-4ec0-9f00-add2ea9b4e38/element
debug: Request received with params: {"using":"xpath","value":"//UIATableView[1]"}
info: Pushing command to appium work queue: "au.mainApp().getTreeForXML()"
debug: Sending command to instruments: au.mainApp().getTreeForXML()
info: [INSTSERVER] Sending command to instruments: au.mainApp().getTreeForXML()
info: [INSTSERVER] Socket data received (8186 bytes)
info: [INSTSERVER] Socket data received (8192 bytes)
info: [INSTSERVER] Socket data received (5420 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":"{\"UIAApplication\":{\"@\":{\"name\":\"Podio\",\"label\":\"Podio\",\"value\":null,\"dom\":null,\"enabled\":true,\"valid\":true,\"visible\":true,\"hint\":null,\"path\":\"/0\",\"x\":0,\"y\":20,\"width\":320,\"height\":548},\">\":[{\"UIAWindow\":{\"@\":{\"name\":null,\"label\":null
info: Pushing command to appium work queue: "au.getElementByIndexPath('/0/0/3')"
debug: Sending command to instruments: au.getElementByIndexPath('/0/0/3')
info: [INSTSERVER] Sending command to instruments: au.getElementByIndexPath('/0/0/3')
info: [INSTSERVER] Socket data received (62 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":{"ELEMENT":"48"}}
info: Responding to client with success: {"status":0,"value":{"ELEMENT":"48"},"sessionId":"43dc50b4-a81b-4ec0-9f00-add2ea9b4e38"}
POST /wd/hub/session/43dc50b4-a81b-4ec0-9f00-add2ea9b4e38/element 200 619ms - 110b
Then trying to do search for table cell inside a UIATableView using chained queries.
driver.find_element(:xpath, '//UIATableView[1]').find_element(:xpath, '//UIATableCell[1]/UIAElement[1]').text
And the log is:
debug: Appium request initiated at /wd/hub/session/43dc50b4-a81b-4ec0-9f00-add2ea9b4e38/element
debug: Request received with params: {"using":"xpath","value":"//UIATableView[1]"}
info: Pushing command to appium work queue: "au.mainApp().getTreeForXML()"
debug: Sending command to instruments: au.mainApp().getTreeForXML()
info: [INSTSERVER] Sending command to instruments: au.mainApp().getTreeForXML()
info: [INSTSERVER] Socket data received (8186 bytes)
info: [INSTSERVER] Socket data received (8192 bytes)
info: [INSTSERVER] Socket data received (5420 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":"{\"UIAApplication\":{\"@\":{\"name\":\"Podio\",\"label\":\"Podio\",\"value\":null,\"dom\":null,\"enabled\":true,\"valid\":true,\"visible\":true,\"hint\":null,\"path\":\"/0\",\"x\":0,\"y\":20,\"width\":320,\"height\":548},\">\":[{\"UIAWindow\":{\"@\":{\"name\":null,\"label\":null
info: Pushing command to appium work queue: "au.getElementByIndexPath('/0/0/3')"
debug: Sending command to instruments: au.getElementByIndexPath('/0/0/3')
info: [INSTSERVER] Sending command to instruments: au.getElementByIndexPath('/0/0/3')
info: [INSTSERVER] Socket data received (62 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":{"ELEMENT":"49"}}
info: Responding to client with success: {"status":0,"value":{"ELEMENT":"49"},"sessionId":"43dc50b4-a81b-4ec0-9f00-add2ea9b4e38"}
POST /wd/hub/session/43dc50b4-a81b-4ec0-9f00-add2ea9b4e38/element 200 561ms - 110b
debug: Appium request initiated at /wd/hub/session/43dc50b4-a81b-4ec0-9f00-add2ea9b4e38/element/49/element
debug: Request received with params: {"using":"xpath","value":"//UIATableCell[1]/UIAElement[1]"}
info: Pushing command to appium work queue: "au.getElement('49').getTreeForXML()"
debug: Sending command to instruments: au.getElement('49').getTreeForXML()
info: [INSTSERVER] Sending command to instruments: au.getElement('49').getTreeForXML()
info: [INSTSERVER] Socket data received (2605 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":"{\"UIATableView\":{\"@\":{\"name\":null,\"label\":null,\"value\":\"rows 1 to 3 of 3\",\"dom\":null,\"enabled\":true,\"valid\":true,\"visible\":true,\"hint\":null,\"path\":\"/0\",\"x\":0,\"y\":64,\"width\":320,\"height\":504},\">\":[{\"UIATableCell\":{\"@\":{\"name\":\"All Field
info: Pushing command to appium work queue: "au.getElementByIndexPath('/0/0/1')"
debug: Sending command to instruments: au.getElementByIndexPath('/0/0/1')
info: [INSTSERVER] Sending command to instruments: au.getElementByIndexPath('/0/0/1')
info: [INSTSERVER] Socket data received (62 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":{"ELEMENT":"50"}}
info: Responding to client with success: {"status":0,"value":{"ELEMENT":"50"},"sessionId":"43dc50b4-a81b-4ec0-9f00-add2ea9b4e38"}
POST /wd/hub/session/43dc50b4-a81b-4ec0-9f00-add2ea9b4e38/element/49/element 200 282ms - 110b
debug: Appium request initiated at /wd/hub/session/43dc50b4-a81b-4ec0-9f00-add2ea9b4e38/element/50/text
debug: Request received with params: {}
info: Pushing command to appium work queue: "au.getElement('50').text()"
debug: Sending command to instruments: au.getElement('50').text()
info: [INSTSERVER] Sending command to instruments: au.getElement('50').text()
info: [INSTSERVER] Socket data received (102 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":"UH OH! LOADING FAILED, CHECK YOUR INTERNET CONNECTION."}
info: Responding to client with success: {"status":0,"value":"UH OH! LOADING FAILED, CHECK YOUR INTERNET CONNECTION.","sessionId":"43dc50b4-a81b-4ec0-9f00-add2ea9b4e38"}
GET /wd/hub/session/43dc50b4-a81b-4ec0-9f00-add2ea9b4e38/element/50/text 200 118ms - 141b
It seems like this query is not built correctly:
au.getElementByIndexPath('/0/0/1')
Instead, it should be:
au.getElementByIndexPath('/0/0/3/0/1')
Note: running from sources d9f0ae7d718e06959854b9b1d3a23306adbee212
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 21 (10 by maintainers)
I’ve created a pull request for this feature on android, so far I’m being ignored: https://github.com/appium/appium-android-driver/pull/111 https://github.com/appium/appium-android-bootstrap/pull/17
Yes, search for an element from another element is not supported. Why do you want to do this anyway? This is exactly what XPath is for in the first place. I.e., instead of doing:
Just do