I'm using xcuitest framework to automate mac application. I get system dialogs when the app is opened again after it crashes. I want to handle the dialog programmatically. But the dialog appears under the process `UserNotificationCenter' instead of the application under test. How can I handle the alert in such case?
Asked
Active
Viewed 261 times
1
-
Do you try to use `InterruptionMonitor` for this? – cesarmarch Jun 04 '19 at 15:05
-
Yes. InterruptionMonitor seems to work but it somehow makes the test to run a longer time. – Prakash Saravanan Jun 06 '19 at 06:48
2 Answers
1
You have two options:
- Use
InterruptionMonitor
(documentation, use-case). This approach is however kinda old and I found, that it does not work for all dialogs and situations. - Create a method, which will wait for some regular app's button. If the app's button (or tab bar or other such XCUIElement) is visible and hittable after your app started, you can proceed with your test and if it's not, you can wait for the
UserNotificationCenter
dialog's button and identify&tap it by its string/position.
I'm using the second approach and its working much better, than the InterruptionMonitor
. But it really depends on your app layout and use-case.

Václav
- 990
- 1
- 12
- 28