TestProject Forum

Same XPath does not work in all iOS

I have recorded test cases in iOS 13.3 but some XPath created by recorder does not work in iOS 13.5.
For example:

I have UIPopOverController which has UITbleview and I have a test where I am selecting row in UITableView.
Recorder is generating following XPath


But I need to change to

By.xpath("//XCUIElementTypeStaticText[@label = ‘Secondary and below’]");

to make it work in iOS 13.5 but it work without change in iOS 13.3.

It’s difficult to change all those instances across my test cases. I need to know what should be done to fix this, I don’t want to modify my script.

Hello @be_ashketchup
Do you have another iOS device who is on a prior version you can try to execute the test on?
Or use our Integration with BrowserStack/SauceLabs to run on a prior version iOS device to see if it does pass.

Let me know of your findings please.

Best Regards, Ran.

Earlier i was running script on iOS 13.2 which was recorded on iOS 13.3, but it was not working which is why i updated my iOS to 13.5 and still not able to run the scripts.

Also, as you mentioned run on iOS emulator how to do that ?
I don’t wanna use BrowserStack / SauceLabs as of now.

Kindly help me understand why xPath is not working…

It will be helpful if someone knows how to resolve this issue. Has anyone face this issue ?

Hello @be_ashketchup.

Can you please contact us in the support chat and we will troubleshoot this issue?

XPath is not native for iOS and XCUITest, they are very slow, fragile and prone to errors.
Appium and TestProject use it as last resort.

It would work much better and consistently if you add accessibility IDs to your app as shown below.
Recorder can pickup these IDs and use them for automation.

Please extract the DOM when using the recorder on both of the devices.
You can do it using the “arrow down” icon from the element explorer widget as shown below.
We will compare the two DOMs to understand if indeed the layout is different and why.

Screen Shot 2020-06-26 at 10.24.36

I want to ask if this recorder works on windows, as a separate tool without having to go to TestProject to get ID? .

Hello @quoctrunggol36.

The recorder is a part of TestProject, you will need to navigate to the TestProject platform and log in to enter the recorder and inspect elements.

If you’re asking since you’re developing test cases using the SDK and would like to view the structure of the page/application, you could always use the driver.getPageSource() method after the page has loaded to check the DOM.

1 Like