Making an In-App Purchase (IAP) on iOS brings an Apple alert and puts the application into the background. If I use the Appium framework for automation, will I be able to interact with these prompts? Bonus if you could point me to an example of it. It was not immediately obvious to me that this was supported, though my understanding is that that UIAutomation framework might support this and that Appium calls into that framework. I'm in the process of evaluating frameworks.
-
your question is not clear to understand.– sameer joshiCommented Dec 9, 2015 at 12:24
-
@sameerjoshi The IAP process involves system prompts that take you outside of your app, e.g. "Do you want to buy a widget for $0.99?" This makes automation a challenge if the automation software loses control once your app is in the background.– Ben FlynnCommented Dec 9, 2015 at 16:31
2 Answers
Appium have capabilities to auto accept or dismiss the alerts, you can use these capabilities to complete your flow, as per your requirements:
autoAcceptAlerts = true
capabilities.SetCapability("autoAcceptAlerts", true);
or
autoDismissAlerts = true
capabilities.SetCapability("autoDismissAlerts", true);
Furthermore, some of the older versions of Appium haven’t worked with this solution, so you might want to try a small workaround with this:
driver.SwitchTo().Alert().Accept();
Note : If Auto accept/dismiss capabilities used, it will accept/dismiss all the alerts of the application automatically.
I have not actually implement this scenario @Ben. But as you said,
- IAP process may take you out of the app. Most probably browser
- In that cases its possible to automate it
I am confident because
- I have automated successfully the scenario where my app also redirect user on browser.
- I'll say it would be the power of Appium to have support for Web and mobile platform in a same & single test.
Please give a try and let us all know if any smarter ways or challenges you face.
-
On iOS In App Purchases do not take you to a web browser, but your app loses focuses and Apple produces dialogs. It may ask for a password, or it may ask if you approve the purchase. In our testing with UIAutomation we have not been able to consistently manage this situation. Perhaps you are thinking of sales of real world goods -- the case I am talking about is virtual goods, the kind you set up in iTuneConnect. Commented Sep 30, 2016 at 17:14