In-App Purchase test. How to differentiate XCUITest vs. UiAutomation popups?

I’m automating an In-App Purchase Test on IOS devices. The test needs to work for both old and new ios devices. That is: the test needs to be able to handle both XCUITest and UiAutomation, when it comes to handling different popups appearing when doing In-App purchase. Popups, such as “sign in to iTunes”, “Confirm your In-App Purchase” etc.
The elements in these popups have different names depending on if XCUITest or UiAutomation is used.

My approach so far is: Findout in runtime if appium is using XCUITest or UiAutomation. Then handle the popups accordingly.

So question is: is there an easy way to findout in runtime if appium is using XCUITest or Uiautomation?

Or should I be taking some completely different approach? Any help is appreciated.

/Alex

I think you using the proper way. I do that also for some capabilities (not the driver one). You can use (you probably using it already):

driver.getCapabilities().getCapability("automationName")

thanks, but I’m not setting the “automationName” in my desired capabilities. I just set the ios version from the device. then Appium decieds automatically what to choose: XCUITest or UiAutomation. In this case “automationName” is empty. At least using the java_client.

You can create a logic if iOS version is less the 9 use UIAUTOMATOR and its more then use XCUITEST

I think for ios version 9.3 up to 10 (not inclusive), both XCUITest/UiAutomator are supported. So that won’t always work.

My first approach was to poll the ios IAP native popups for either “XCUIElementTypeAlert” or “UIAAlert” elements and see which one was found. Using driver.findElementsByClassName(...). But turns out appium is automatically transforming “UIAAlert” to “XCUIElementTypeAlert”, so that didn’t work.

Looking for next approach to try…

I used this approach in the end:

executed this from the command line “xcodebuild -version” and parsed the xcode major version. For major version 8 and above use XCUITest, else use UiAutomation.

Example:
-> xcodebuild -version
<- Xcode 8.3.3
Build version 8E3004b