Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift UI Test Static Text Value

I have a label that gets its text assigned after a certain action happens, and I want to test that the text it has been assigned is correct with a UI test.

I am getting the XCUIElement with .descendantsMatchingType(.StaticText).elementBoundByIndex(UInt(3))

The element is a staticText, and the element.value is not returning anything useful, and I'm unable to find another way of getting any sort of useful value from the staticText, besides the debugDescription. However, it says in the docs that the debugDescription is unreliable and should not be used for the actual tests.

How can I verify that this label has the correct text?

like image 286
Alex Avatar asked Sep 06 '25 19:09

Alex


1 Answers

This has been answered with a recent update to XCUIElement; there is now a label property that gets the text from a .StaticText element.

like image 129
Alex Avatar answered Sep 09 '25 17:09

Alex