Vish
Vish

Reputation: 2164

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

My app under test has an element (a UIAStaticText) 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?

Upvotes: 1

Views: 2768

Answers (1)

Vish
Vish

Reputation: 2164

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"];

Upvotes: 1

Related Questions