I am writing my XCUITest's for my app.
I am declaring the alert in order to use waitForExpectationsWithTimeout
to make my test asynchronous....However it is throwing the error Variable used within its own initial value
on the declaration of alert
on line 5.
let timeout = NSTimeInterval()
let app = XCUIApplication()
let exists = NSPredicate(format: "exists == 1")
let alert = alert.buttons["OK"]
testCase.addUIInterruptionMonitorWithDescription("Enable Notifications") { (alert) -> Bool in
alert.buttons["OK"].tap()
return true
}
self.buttons["Enable notifications"].tap()
testCase.expectationForPredicate(exists, evaluatedWithObject: alert, handler: nil)
testCase.waitForExpectationsWithTimeout(timeout, handler: nil)
app.tap()
Can someone tell me why it is throwing this error and what I can do to fix this. Thanks in advance.