lundi 31 août 2015

Xcode UI Testing - Asserting actual label values when using accessibility labels

The question is actually really simple:

Is there a way to assert the displayed value from a specific label (e.g. UILabel) when using an accessibility label on this object?

As far as I see it, all the assertions (e.g. XCTAssertEquals) made in the examples, be it from a WWDC Talk or Blogposts, are only checking if an element exists for a query like XCTAssertEquals(app.staticTexts["myValue"].exists, true) or if the number of cells in a table is correct XCTAssertEquals(app.tables.cells.count, 5). So, when avoiding accessibility labels it's possible to check if an object has a certain value displayed, but not which object / element. And when using accessibility labels, it robs me of the opportunity to query against the displayed values, because app.staticTexts["myValue"] will now fail to deliver a result but app.staticTexts["myAccessibilityLabel"] will hit.

Assuming I want to test my "Add new Cell to table" functionality, I can test that there is really a new cell added to the list, but I have no idea if the new cell is added on the top or the bottom of the list or somewhere in between.

Think what you will, but for me an easy way to check if a specific element has a certain value should be a no-brainer when it comes to UI Testing.

It is still possible that due to the missing documentation I might overlook the obvious. If so, just tell me.

Aucun commentaire:

Enregistrer un commentaire