xpath selector doesn't work if search context is an element (not a driver)
See original GitHub issuedriver.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
Issue Analytics
- State:
- Created 9 years ago
- Comments:21 (10 by maintainers)
Top Results From Across the Web
Python Selenium find element XPath doesn't work
This will work with assumption you want data of that page not of any specific element: import selenium from selenium import webdriver from ......
Read more >Finding element within an element doesn't work using Xpath
The problem is simple. I searched for existing issues with keyword "Xpath" but was not able to find this. So I am going...
Read more >Different XPath writing techniques for locating elements in ...
In this article we will see most important locator type to locate element. With XPath you can almost locate any element in the...
Read more >Locators In Selenium WebDriver With Examples - LambdaTest
CSS Selector in Selenium should be opted if you cannot locate an element using ID or Name locators. It can be chosen over...
Read more >Practical XPath for Web Scraping - ScrapingBee
In this tutorial, we are going to see how to use XPath expressions in your Python code to extract data from the web....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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