Appium 1.6 beta3 : IOS and find_element(:xpath) don't find anything

Hello,
Since I’ve udpated to Appium 1.6 beta3 and XCUITest, on iOS Simulator, with my app, all my find_element :xpath, search are failling. I have 0 result.
For the exact same app and the exact same search, they’re all bad now.

As exemple find_element(:xpath, “//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]”) was suppose to find me the Text field on the page and I have “Selenium::WebDriver::Error::NoSuchElementError: An element could not be located on the page using the given search parameters.” as answer now.
If I re-install Appium 1.5.3 like before, it’s ok.

I’ve tried 1.6. beta3 without XCUITest (by keeping by default UIAutomator and it’s OK to.

So the problem is with XCUITest.

Note that find_element(:name, “my_name”) is still OK with XCUITest (but regex is not working anymore, but that’s another problem I guess).

Logs Appium 1.6 WITH XCUITest :

[HTTP] <-- POST /wd/hub/session/2609d4e3-f2ff-47b7-a97c-ff3f81ef56f7/element 500 5352 ms - 164
clear
[HTTP] --> POST /wd/hub/session/2609d4e3-f2ff-47b7-a97c-ff3f81ef56f7/element {“using”:“xpath”,“value”:"//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIASecureTextField[1]"}
[MJSONWP] Calling AppiumDriver.findElement() with args: [“xpath”,"//UIAApplication[…
[debug] [XCUITest] Executing command ‘findElement’
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, accessibility id
[debug] [BaseDriver] Waiting up to 5000 ms for condition
[JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8100/session/8B11CE89-63FE-4D7B-99B2-167F6A8427D1/element] with body: {“using”:“xpath”,“value”:"/…
[JSONWP Proxy] Got response with status 200: {“value”:{“using”:“xpath”,"…
[debug] [BaseDriver] Waited for 140 ms so far
[JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8100/session/8B11CE89-63FE-4D7B-99B2-167F6A8427D1/element] with body: {“using”:“xpath”,“value”:"/…
[JSONWP Proxy] Got response with status 200: {“value”:{“using”:“xpath”,"…
[debug] [BaseDriver] Waited for 782 ms so far
[JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8100/session/8B11CE89-63FE-4D7B-99B2-167F6A8427D1/element] with body: {“using”:“xpath”,“value”:"/…

Logs with Appium 1.6 beta3 WITHOUT XCUITest:
[MJSONWP] Calling AppiumDriver.findElement() with args: [“xpath”,"//UIAApplication[…
[debug] [iOS] Executing iOS command ‘findElement’
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, -ios uiautomation, accessibility id
[debug] [BaseDriver] Waiting up to 5000 ms for condition
[debug] [UIAuto] Sending command to instruments: au.mainApp().getTreeForXML()
[debug] [Instruments] [INST] 2016-10-06 15:15:53 +0000 Debug: Got new command 4 from instruments: au.mainApp().getTreeForXML()
[debug] [Instruments] [INST] 2016-10-06 15:15:53 +0000 Debug: evaluating au.mainApp().getTreeForXML()
[debug] [Instruments] [INST] 2016-10-06 15:15:53 +0000 Debug: evaluation finished
[debug] [Instruments] [INST] 2016-10-06 15:15:53 +0000 Debug: responding with:alid":true,“visible”:true,“hint”:null,“path”:"/0/0",“x”:0,“y”:0,“width”:375,“height”:667},">":[{“UIAImage”:{"@":{“name”:“background”,“label”:null,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/0",“x”:0,“y”:0,“width”:375,“height”:667},">":[]}},{“UIAScrollView”:{"@":{“name”:null,“label”:null,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/1",“x”:0,“y”:0,“width”:375,“height”:667},">":[{“UIAImage”:{"@":{“name”:“logo-logo-white-vector”,“label”:null,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/1/0",“x”:147.5,“y”:65,“width”:80,“height”:30},">":[]}},{“UIAButton”:{"@":{“name”:" Sign in with logo",“label”:" Sign in with logo",“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/1/1",“x”:31,“y”:254,“width”:313,“height”:42},">":[]}},{“UIAActivityIndicator”:{"@":{“name”:“In progress”,“label”:“In progress”,“value”:“1”,“dom”:null,“enabled”:true,“valid”:true,“visible”:false,“hint”:null,“path”:"/0/0/1/2",“x”:41,“y”:265,“width”:20,“height”:20},">":[{“UIAImage”:{"@":{“name”:null,“label”:null,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:false,“hint”:null,“path”:"/0/0/1/2/0",“x”:41,“y”:265,“width”:20,“height”:20},">":[]}}]}},{“UIAStaticText”:{"@":{“name”:“OR”,“label”:“OR”,“value”:“OR”,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/1/3",“x”:180.5,“y”:326,“width”:15,“height”:11},">":[]}},{“UIAStaticText”:{"@":{“name”:null,“label”:"",“value”:"",“dom”:null,“enabled”:true,“valid”:true,“visible”:false,“hint”:null,“path”:"/0/0/1/4",“x”:31,“y”:342,“width”:313,“height”:0},">":[]}},{“UIAButton”:{"@":{“name”:“EMAIL”,“label”:“EMAIL”,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/1/5",“x”:70,“y”:367,“width”:274,“height”:12},">":[]}},{“UIAImage”:{"@":{“name”:“email”,“label”:null,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/1/6",“x”:31,“y”:379,“width”:24,“height”:24},">":[]}},{“UIATextField”:{"@":{“name”:null,“label”:null,“value”:"",“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/1/7",“x”:70,“y”:388,“width”:274,“height”:15},">":[{“UIATextField”:{"@":{“name”:null,“label”:null,“value”:"",“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/1/7/0",“x”:70,“y”:388,“width”:274,“height”:15},">":[]}}]}},{“UIAButton”:{"@":{“name”:“PASSWORD”,“label”:“PASSWORD”,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/1/8",“x”:70,“y”:420,“width”:274,“height”:12},">":[]}},{“UIAImage”:{"@":{“name”:“password”,“label”:null,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/1/9",“x”:35,“y”:432,“width”:16,“height”:24},">":[]}},{“UIASecureTextField”:{"@":{“name”:null,“label”:null,“value”:"",“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/1/10",“x”:70,“y”:439,“width”:274,“height”:15},">":[{“UIASecureTextField”:{"@":{“name”:null,“label”:null,“value”:"",“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/1/10/0",“x”:70,“y”:439,“width”:274,“height”:15},">":[]}}]}},{“UIAButton”:{"@":{“name”:“Sign in”,“label”:“Sign in”,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/1/11",“x”:31,“y”:480,“width”:313,“height”:42},">":[]}},{“UIAActivityIndicator”:{"@":{“name”:“In progress”,“label”:“In progress”,“value”:“1”,“dom”:null,“enabled”:true,“valid”:true,“visible”:false,“hint”:null,“path”:"/0/0/1/12",“x”:41,“y”:491,“width”:20,“height”:20},">":[{“UIAImage”:{"@":{“name”:null,“label”:null,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:false,“hint”:null,“path”:"/0/0/1/12/0",“x”:41,“y”:491,“width”:20,“height”:20},">":[]}}]}},{“UIAButton”:{"@":{“name”:“Log in as Guest”,“label”:“Log in as Guest”,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/1/13",“x”:148.5,“y”:530,“width”:78,“height”:25},">":[]}},{“UIAImage”:{"@":{“name”:null,“label”:null,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:false,“hint”:null,“path”:"/0/0/1/14",“x”:369.5,“y”:558,“width”:2.5,“height”:7},">":[]}},{“UIAImage”:{"@":{“name”:null,“label”:null,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:false,“hint”:null,“path”:"/0/0/1/15",“x”:310,“y”:661.5,“width”:7,“height”:2.5},">":[]}}]}}]}},{“UIAWindow”:{"@":{“name”:null,“label”:null,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:false,“hint”:null,“path”:"/0/1",“x”:0,“y”:0,“width”:375,“height”:667},">":[{“UIAStatusBar”:{"@":{“name”:null,“label”:null,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:false,“hint”:null,“path”:"/0/1/0",“x”:0,“y”:0,“width”:375,“height”:0},">":[]}}]}}]}}}
[debug] [Instruments] [INST] 2016-10-06 15:15:53 +0000 Debug: Running system command #5: /usr/local/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/build/lib/bin/command-proxy-client.js /var/folders/s9/1ryws64x3qj4ftkymtfylqv00000gp/T/instruments_sock 2,{“status”:0,“value”:{“UIAApplication”:{"@":{“name”:“Showcase”,“label”:“Showcase”,“value”:null,“dom”:null,“enable…
[debug] [UIAuto] Socket data received (5169 bytes)
[debug] [UIAuto] Got result from instruments: {“status”:0,“value”:{“UIAApplication”:{”@":{“name”:“Showcase”,“label”:“Showcase”,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0",“x”:0,“y”:0,“width”:375,“height”:667},">":[{“UIAWindow”:{"@":{“name”:null,“label”:null,“value”:null,“dom”:null,“enabled”:true,"v
[debug] [UIAuto] Sending command to instruments: au.getElementByIndexPath(’/0/0/1/10’)
[debug] [Instruments] [INST] 2016-10-06 15:15:54 +0000 Debug: Got new command 5 from instruments: au.getElementByIndexPath(’/0/0/1/10’)
[debug] [Instruments] [INST] 2016-10-06 15:15:54 +0000 Debug: evaluating au.getElementByIndexPath(’/0/0/1/10’)
[debug] [Instruments] [INST] 2016-10-06 15:15:54 +0000 Debug: evaluation finished
[debug] [Instruments] [INST] 2016-10-06 15:15:54 +0000 Debug: responding with:
[debug] [Instruments] [INST] 2016-10-06 15:15:54 +0000 Debug: Running system command #6: /usr/local/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/build/lib/bin/command-proxy-client.js /var/folders/s9/1ryws64x3qj4ftkymtfylqv00000gp/T/instruments_sock 2,{“status”:0,“value”:{“ELEMENT”:“0”}}…
[debug] [UIAuto] Socket data received (38 bytes)

Thanks !

For XCTest prefix of Xpath elements changed, try to update your locators syntax as bellow:

// XCUIElementTypeApplication[1]/ XCUIElementTypeWindow[1]/ XCUIElementTypeScrollView[1]/ XCUIElementTypeTextField[1]"

Thanks for the answer, it’s ok now, after reading the doc, I understand and I’ve changed my code.
Have a nice day :slight_smile:

I have one more question about xpath : how can I see the xpath of the element of my App ?
Because with appium App 1.5.3, I used the Inspector and it was very helpful. But with the appium beta, I don’t have this inspector and it looks like the elements doesn’t have the same name.

As exemple :
UIATextField[1] is now XCUIElementTypeTextField[1], it’s ok.
I found that UIATableCell[10] is now found with XCUIElementTypeCell[10], so ok, I had to delete the “Table”

But for the element UIATableView[1], I’m not able to find it anymore…

I was thinking that I can have the path of an element like this :
find_element(:name, “Cancel”).xpath
But I have “ArgumentError: wrong number of arguments (0 for 1)”.

So if you’ve got a tool or a way to find xpath for XCUITest, it will be great !
Thanks

I’ve found this xpath inspector and it’s working with xcode 8 app : https://github.com/mykola-mokhnach/Appium-iOS-Inspector
So i’ve got answer to all my questions !

Can you please tell us how to open appium inspector with xcode 8 and appium 1.6 beta.

Hello,
You have to clone the git project https://github.com/mykola-mokhnach/Appium-iOS-Inspector4 and follow the read me here : https://github.com/mykola-mokhnach/Appium-iOS-Inspector/blob/master/README.md

It’s very simple and it’s working great