Click Alert View using KIF

1.5k Views Asked by At

So I have a test that is running in KIF that wants to click the alert view's primary button (in this call the label is called "Call".

But the problem is that the tableview also has buttons called "Call" on it. I was able to isolate the view of the table cell call buttons and make KIF click them specifically, but I can't figure out how to make it reliably click the Alert's View call vs any other call.

It's possible also that the error is in the fact that it's trying to tap before the alert view is up, but I'm not sure how to make it wait for that when any waitForAccessibiltyLabel:Call will find the other call buttons on the page.

1

There are 1 best solutions below

2
On

To prevent KIF from tapping one of the tableView's "Call" button, add a delay. This will allow the alert to pop up, and then KIF should tap the alertView's "Call" button.

E.g.,

[tester tapViewWithAccessibilityLabel:@"Call"]; // The view in your table
[tester waitForTimeInterval:1]; // Wait 1 second for the alert to pop up
[tester tapViewWithAccessibilityLabel:@"Call"]; // This will tap the "Call" button in your alertView

Perhaps because the alertView's window is above your application's window, KIF finds the alert's button first and taps that. Just give the alertView a second to present itself.