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:

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

Replies

The in-app purchase drawer lives inside the app context of a separate process, outside the context of the app you are developing.

Your variable, app, knows about the UI context of your built application, but does not know about the contexts outside of it- such as the in-app purchase sheet.

  • Is there any way to find out the bundle identifier for the purchase drawers so we could successfully touch the Purchase button during an XCUITest? This would be helpful as this is currently only possible via Appium test scripts and I would rather move towards a full Native test suite using XCUITest if possible.

Add a Comment