dimanche 18 octobre 2020

XCUItest correct way to wait for a staticText label to update?

Hi all I'm using Swift to write some UI tests for my iOS application. I have a staticText element with a label that updates when a user navigates to a screen. What happens is that there is a GET request behind the scene that fetches the updated label from a database. The problem is that I don't know how to wait for a label change.

I've tried the following:

    let elementExists = element.waitForExistence(timeout: 10)

    if elementExists {
        XCTAssertTrue(element.exists)
    }

The problem with this is that the element, in this case the staticText, already exist. So this does nothing. What I need is to wait for the staticText.label to update. How can I achieve this? I know what value I expect but simply doing

XCTAssertEqual(newValue, staticText.label)

Will fail the test instantly. Because the value in the staticText.label is still the old value.

Aucun commentaire:

Enregistrer un commentaire