Issues running XCUITests in Xcode 9.3

After updating xcode my UI tests are much more flaky. My main issue right now is that the '.waitForExistence(timeout: ) doesn't seem to be working at all. I run and watch the test run and it fails before 15 seconds pass. The test is selecting settings. The wait provides enough time for the screen to transition and the activitiy indicator to process. The indicator finishes within the first 5 seconds. When I look at the screen shot it shows that test is attempting to verify the element exists right away while the activity indicator is still pressent.


Code:


app.buttons["settingsButton"].tap()

XCTAssertTrue(app.staticTexts["Settings"].waitForExistence(timeout: 15))

let measurementsButton = app.tables.cells.buttons["Measurement"]

let measurementTitle = app.tables.cells.staticTexts["Standard"]

XCTAssertTrue(measurementTitle.isSelected)


Anyone else seeing issues like this?

Replies

I have the same problem. But it seems to be more related to the staticTexts[" "] search. When I inspect all the static texts I can see what I am looking for, but when I specify the string it cannot be found.

I discovered that there was a new line in my static text and because of that the text wasn't matching. This was not a problem in Xcode 9.2, for Xcode 9.3 instead everything was failing.

Looks to me that your second assert will always fail because it is testing for the staticText in the cell and not the cell itself. If accessibility is enabled for the cell you can use app.tables.cells[Standard"].isSelected.

I figured out the problem. It wasn't that the elements were or were not in existance it was that there was another view on top of the elements. So the wait was not doing any good.


JohnFromNesbru good call on the cell, the way it is currently written works most of the time but this would make my code cleaner.