Need help handling system alerts; what does UIAutomationHelper.m do?

542 views
Skip to first unread message

Vishwanath Venugopalakrishnan

unread,
May 19, 2015, 7:21:49 AM5/19/15
to kif-fr...@googlegroups.com
Hey guys,

I am automating an iOS application that works with the user's photos and videos. I finally reached KIF after trying (futilely) various automation frameworks for iOS - chiefly T-Plan Robot and UI Automation. 
I am somewhere in-between a developer and a QA tester, so suffice it to say I am new to Objective C (but willing and able to learn). 

Here's the problem:
  • My app deletes the user's photos at one stage. This prompts an iOS dialog, "Allow Application to Delete X Photos?" with two buttons "Don't Allow" and "Delete."
  • So far only UI Automation has been able to handle this system alert, using the onAlert() alert-handler. 
  • I have been unable to figure out an equivalent way in KIF. 
While tooling around the source I jumped up in glee when I saw "UIAutomationHelper.m". I did notice the method "acknowledgeSystemAlert" in UIAutomationHelper.m ... but was unable to figure out how to use it. Any pointers?

On another note, the UIAutomationHelper.m does seem sparse, with lots of @interface's but only one @implementation. Is this a work in progress, maybe slated for another release?


Vishwanath Venugopalakrishnan

unread,
May 20, 2015, 4:48:19 PM5/20/15
to kif-fr...@googlegroups.com
Okay, further to my post: I am running my tests on an iOS 8.3 device (which is a requirement unfortunately; so simulators are out of the question).

"Yes, KIF can now dismiss system alerts, but only when running on the simulator."

:(

Vishwanath Venugopalakrishnan

unread,
May 25, 2015, 7:12:07 AM5/25/15
to kif-fr...@googlegroups.com
Any help or any pointers on this?

mike...@aol.com

unread,
May 25, 2015, 8:59:43 AM5/25/15
to kif-fr...@googlegroups.com
Hi Vishwanath,
I'm sympathetic to your need to dismiss a system alert. I needed to do the same thing.
The inability to do is an Apple limitation, not a KIF limitation. Apple prevents one app from being able to interact with other apps for the sake of security. So a hacker cannot steal your protected data. Since KIF runs as part of your App Under Test process, it has the same permissions as the app itself. 

Instead what I did was for the UI automation that I'm doing ON THE DEVICE, I worked with our developers to disable the code that causes any system Alerts to occur, i.e. Push Notifications, etc. You can create a specialized target that uses prepropcessor directives (i.e. UITESTS=1) without affecting the code that ships to customers.  Wrap the app code in #ifdef (UITESTS) ...
I won't go into the details here as this isn't the place for that. 

For the one-off cases, you can either do them manually, choose to use Apple Instruments (part of Xcode), or run those particular tests using KIF on the simulator.

Despite these limitations, KIF is by far the best UI automation tool out there.

Sorry it's not the answer you want, but hope I helped just the same.


--
You received this message because you are subscribed to the Google Groups "KIF iOS Automated Testing Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kif-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vishwanath Venugopalakrishnan

unread,
May 26, 2015, 3:26:22 AM5/26/15
to kif-fr...@googlegroups.com
Hi Mike, 

Thanks for the reply. I guessed as much; i.e. that it was an Apple limitation that was preventing the alert from being interacted with. 

These system alerts are unfortunately an integral part of the tests of the app - as our app deals primarily with managing (which includes deleting) media on the user's phone -  and are encountered practically in every test-case. 
Therefore, disabling these alerts is not an option for us. 

Besides, we have had a clear mandate from the start, that our tests should be on real devices, not simulators. Having said that, I will explore the simulator option and if it works, push it as an alternative.

I agree that KIF does have a lot of compelling benefits over Instruments' UI Automation - and it is in active development and has an engaging user community. 

Given that KIF loads the UI Automation framework via a dlopen() I was wondering:
  • Is there any way to use the UI Automation Framework commands within KIF?
  • Specifically, the onAlert() logic that enables dismissal of an alert in UI Automation: is there any way to somehow use this in KIF code? Because that would help with this problem.

Keith Ray

unread,
May 26, 2015, 9:13:43 AM5/26/15
to kif-fr...@googlegroups.com

Tony Mann

unread,
May 26, 2015, 12:35:38 PM5/26/15
to kif-fr...@googlegroups.com
The Travis folks need to buy a few of these :-)

Tony

Tony Mann

unread,
May 27, 2015, 12:48:52 PM5/27/15
to kif-fr...@googlegroups.com
KIF could be extended to use more of the UIAutomation framework.  Perhaps this is something you would consider coding up and then submitting a pull request? If you need help, then consider submitting an issue describing what you need, and then myself and other members can jump in and discuss it with you.

Tony

Vishwanath Venugopalakrishnan

unread,
Jun 3, 2015, 6:26:04 AM6/3/15
to kif-fr...@googlegroups.com
Hi Tony, 
I'd definitely love to contribute. It might have to wait for a bit though until I can find enough time. 

In the meantime I tried out Mike's suggestion above to use the simulator - and the alert is not getting dismissed on the simulator either. 
The simulator is an iOS 8.3 / iPhone 6. "Enable UI Automation" is turned on in the settings.

Up till this point I was trying out KIF using Cocoapods. I tried the alternative described in the docs and tried acknowledgeSystemAlert with head (commit b724348 Jun 2). No luck.

Any tips on where I am going wrong? Any other info I should provide?

Tony Mann

unread,
Jun 9, 2015, 9:12:46 PM6/9/15
to kif-fr...@googlegroups.com
Can you debug into the KIF code and look for clues as to why it is not working?

Tony
Reply all
Reply to author
Forward
0 new messages