How to acknowledge system alerts automatically using KIF test framework? - ios

I use KIF to test the UI for continuous integration. When the app is the first launch on a device (or iOS Simulator), the system will show some alert views for security. How can KIF automatically acknowledge system alerts to prevent test from failure?

The best way is to use [tester acknowledgeSystemAlert]. It will click the last button in the system alert :)
For more information see this github thread.

Related

How do I target in-app purchase drawer element with XCUITEST?

I am trying to write a UI test for our app's IAP using a sandbox account. However, when trying to tap this purchase button, the test is unable to find this element:screenshot of in-app-purchase prompt
I've tried targeting this element by its button name and label name with no success. During the UI recording, when tapping this button, Xcode freezes completely and I am forced to shut Xcode down. I've also tried debugging at this step and when I print out "app.debugDescription" in the console, this button nor any of the other elements in this purchase drawer is returned.
Failing line of code:
app.buttons["Purchase"].tap()
Error message:
No matches found for Elements matching predicate '"Purchase" IN identifiers'
Xcode Version: 13.2.1
iOS Version tested (real iPhone device): 15.3.1
Previously, Apple has not permitted any testing of IAP at all. Recently they introduced testing to the StoreKit framework, but it's at the unit testing level; I wouldn't be surprised if they're programmatically blocking access to automation for security reasons.
If this were to work you'd need to find the bundle identifier of the application that's "running" (the StoreKit window) and interact with that. I unfortunately don't have an application available (one with a purchase available) to allow me to look into this for you.
A forced tap on the coordinates (I always add a few pixels to the x and y for reliability) should work. Never ideal, but might be your only hope.
Another option would be to set the auto-accept alerts capability? It might work. capabilities.SetCapability("autoDismissAlerts", true)

Automatically dismiss iOS Alerts when automating an app with Appium

I am using Ruby in a Cucumber automation framework to automate my Android and iOS application. I am using Appium 1.6.4 beta as it supports iOS 10.2.
When the Appium server first installs the iOS app on the device it is prompted with an Alert Dialog asking if I want to allow notifications. With Appium as far as I can tell the "autoAcceptAlerts" capability does not currently work.
My main question is how would I go about checking if the alert dialog is there and then use something like find_element to press the "Allow" button but not have to edit my feature files. Is there a way I can use my "Log in as an Existing User" step to check for the alert and dismiss it if it's there and if not just continue with the login flow?
I tried to use find_element(xpath to OK button).exists? to make an if/else statement but I think I'm just doing it wrong. If the alert is not present the step fails and my test run stops.
I'm sorry if this question was answered somewhere on her but I've been unable to find a good answer for this question myself. Thank you for any help you can provide.
According to documentation from the Appium team it appears as though the desired capability for automatically accepting all dialogs is broken. As such I have hard-coded the action rather than relying on appium. Perhaps this will be fixed in the next version.
You can use #driver.switch_to.alert.accept to Accept or #driver.switch_to.alert.dismiss to dismiss the Alert.
If you are unsure about the alert, use begin/rescue to handle the exception

Test for app closing with Calabash

Our iOS app opens links in Safari. Is it possible to use a Calabash test to check that our app goes into the background when particular links are clicked?
No. Once the link is touched and Safari becomes the frontmost app, the cucumber processes loses connection with the calabash server and there is no way for calabash to interact with your app.

Using Instruments to test an iOS app without having source code of the application [duplicate]

I would like to use UIAutomation via Instruments in Xcode to test an app on my iOS device. Is it possible to do so without having to build the source code? The reason for this is that our team will have testers who will be writing automation scripts to test the apps on our devices, but we don't want them to all go through syncing to latest builds and compiling it through Xcode. Does anyone know if this is possible through UIAutomation or possibly through a 3rd party application?
Thanks.
You could make UIAutomation tests without the source code, but you will not see your symbols and you cant see where in your code your app is hanging.
You still can see if there is a routine that is taking to long to run, but you wont e able to see witch one or the call stack
to make your tests without the source code just open the automator and bind your test with an application installed on the device

Using Instruments to test an iOS app without having source code to the application

I would like to use UIAutomation via Instruments in Xcode to test an app on my iOS device. Is it possible to do so without having to build the source code? The reason for this is that our team will have testers who will be writing automation scripts to test the apps on our devices, but we don't want them to all go through syncing to latest builds and compiling it through Xcode. Does anyone know if this is possible through UIAutomation or possibly through a 3rd party application?
Thanks.
You could make UIAutomation tests without the source code, but you will not see your symbols and you cant see where in your code your app is hanging.
You still can see if there is a routine that is taking to long to run, but you wont e able to see witch one or the call stack
to make your tests without the source code just open the automator and bind your test with an application installed on the device

Resources