Vish Vish - 2 years ago 269
iOS Question

Xcode UI Testing (Objective C): find element by Accessibility Label

My app under test has an element (a

) which has accessibility enabled (with the accessibility-label "Progress").

Accessing this element using Swift is easy and well-documented. But my app's source is in Objective C.

How do I access this element using Xcode UI Testing and Objective C?

Answer Source

I found one way to do this. This does get me the correct element - but I feel there has to be a simpler answer that does not rely on me knowing the element's type (staticText).

If anyone has a better answer, you are welcome to contribute.

XCUIElement *progressTextByAccessibility = [[app staticTexts] elementMatchingType:XCUIElementTypeStaticText identifier:@"Progress"];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download