hey012983
hey012983

Reputation: 61

UITesting Verify that checkmark exists in table cell

Below is a picture of the table I'm trying to UItest. I need to verify that the checkmark exists next to "AU Auto" (indicating that it is selected). I've tried looking at the app's debugDescription to find anything that resembled a checkmark at all, but there was nothing. I'm a beginner, so I was lost after that point.

let app = XCUIApplication()
po print(app.debugDescription)

enter image description here1

Upvotes: 3

Views: 1153

Answers (2)

For future reference:

Currently for me is working in the following way (I said currently, because, i remember that previously while on Testing environment, i added a special label to denoted selection):

XCTAssertTrue(app.tables.cells.element(boundBy: 0).isSelected)

Upvotes: 3

Charles A.
Charles A.

Reputation: 11123

The first thing you can try is to open the Accessibility Inspector and see if any of the accessibility traits are different on the selected cell. Then you can check the accessibilityTraits property of the XCUIElement representing that cell in your UI test.

If you find that there is not a differentiating factor in the accessibility traits, you can always change the accessibilityLabel on your cells to something indicating the check mark is visible on selection and change it back on deselection. This would potentially improve the accessibility of your app anyhow, assuming nothing else indicates the check mark is visible.

Upvotes: 1

Related Questions