Sometimes under UITests in Xcode the compiler try to tap the button before it is loaded and presented. Then arise a problem like no matched found for...
.
But the simple solution for this is:
sleep(1) //wait 1 second and give `mybutton` time to load and be accessible for uitests
mybutton.tap()
But this is horrible since I cannot put there 0.1
as a parameter. And it makes me annoying to wait 1 second before a lot of buttons.
Is there a way to wait until it is visible for uitests?
You should create an XCTestExpectation and wait for it to be fulfilled
expectationForPredicate(NSPredicate(format: "hittable == true"), evaluatedWithObject: mybutton, handler: nil)
waitForExpectationsWithTimeout(10.0, handler: nil)
mybutton.tap()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With