Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add XCTWaiter ? #1

Open
eonist opened this issue May 10, 2023 · 1 comment
Open

Add XCTWaiter ? #1

eonist opened this issue May 10, 2023 · 1 comment

Comments

@eonist
Copy link
Owner

eonist commented May 10, 2023

// function to wait for an ui element to appear on screen, with a default wait time of 20 seconds
// XCTWaiter was introduced after Xcode 8.3, which is handling better the timewait, it's not failing the test.  It uses an enum which returns: 'Waiters can be used with or without a delegate to respond to events such as completion, timeout, or invalid  expectation fulfilment.'
@discardableResult
func uiElementExists(for element: XCUIElement, timeout: TimeInterval = 20) -> Bool {
    let expectation = XCTNSPredicateExpectation(predicate: NSPredicate(format: "exists == true"), object: element)
    let result = XCTWaiter().wait(for: [expectation], timeout: timeout)
    guard result == .completed else {
        return false
    }
    return true
}
@eonist
Copy link
Owner Author

eonist commented May 10, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant