I am trying to use the XCode 7 UITesting for an Menubar app like Dropbox, 1Password on Mac OS X. Is this possible to automate the UI testing using the latest feature offered by Xcode 7? I understand the UI Testing works for an iOS app, but demo never show if it works OS app or not in the video. If it works for an OS X app, but will it works for menubar app? Please guide me through this problem.
I found a better solution to this problem, motivated by this answer: https://stackoverflow.com/a/5384319/96737
Instead of removing the Dock capability from the Info.plist, it's better to set the application's "activation policy" as "accessory" programmatically.
In swift3 via Xcode 8.1:
func applicationDidFinishLaunching(_ aNotification: Notification) {
NSApp.setActivationPolicy(NSApplicationActivationPolicy.accessory)
}
The biggest benefit is that it works in runtime and in UI testing without modifications. You don't need to activate or desactivate the activation policy depending on wether you're running the application inside a UI test or not.
It just works.
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