How to write iOS Class Chain Strategy for Xpath axes?


#1

Can you please help me how to write iOS Class Chain for the below Xpath ?

  1. //XCUIElementTypeStaticText[@name=‘Next’]/following::XCUIElementTypeStaticText[1]

  2. //XCUIElementTypeStaticText[contains(@value,‘What’)]/ancestor::XCUIElementTypeTextView[1]


#2

I’m afraid this is not possible. Class chain locators don’t support axes


#3

Thank you! Please let me know any other alternative methods to achieve above xpath conditions. Xpath is very slow for IOS Appium Test execution.


#4

For the second one I would try something like

**/XCUIElementTypeTextView[$type == 'XCUIElementTypeStaticText' AND value CONTAINS 'What'$]

The first one is more tricky. Most likely it will be necessary to perform several class chain queries, although I’m not quite sure these all are going to be much faster than the single given xpath