0

On running purchase UITests with XCUitest, sometimes after tapping on the purchase button in the IOS native pop-up

Sign-in Required

doesn't display for a long time (more than 2 min).

The tests are running on a real device(iPhone 6 ios 12).

I've tried to reproduce it manually with no success.

Every time I tried it manually it works fine and most of the time it works fine with the automatic test.

This is the code that waits for the alerts and handles with the alerts with "addUIInterruptionMonitor"

func PurchaseTest1(elementName: String) -> Bool {

    if TestUtilities.wait(forMax: 120.0, condition: { return app.buttons[elementName].exists }, doPerIteration: { self.app.swipeDown() } ) == false {
        return false
    }
    return true
}

It's waiting for an element to appear, after every iteration, it swipes down to call to "addUIInterruptionMonitor" to check if there is an iOS pop-up to handle.

Most of the time it works and the pop-up appear but sometimes pop-up doesn't appear at all (I can see in the screenshots that I have for every test).

Kampai
  • 22,848
  • 21
  • 95
  • 95
  • Did you try to click on the button one more time ? – cesarmarch Aug 20 '19 at 12:45
  • @cesarmarch You can't click on the button again because when you tap on a purchase button for the first time loader appears and the purchase process starts and the user isn't able to do anything in the app. – nir barzilay Aug 21 '19 at 05:03

1 Answers1

0

I had a similar problem. I saw network error, and some time didn't see any errors. I would do the following steps, I hope, It will fix your issue.

  • reset your device; When I was debugging an issue, I realize there is some certificate related issue that causing this problem.

  • I think you are making apple purchase, Sandbox allows for a certain time for one user. You can't buy a continuous basis like running over and over again. May be 30 min before you can start purchase again using the same users

  • Under subscription, Make sure you don't have an active subscription, It can be already purchased and didn't show that button

I think the test will pass if you change device and use new apple sandbox users.

N..
  • 906
  • 7
  • 23
  • N.. thanks for your answer But I already did all those things before each test(except the reset of the device) Before every purchase test I'm entering to the iOS settings app and disconnect from the current sandbox account -> after that I start the test with the app Any other suggestions to avoid this issue? – nir barzilay Aug 21 '19 at 05:09
  • @nirbarzilay - You can reset device before starting tests using command line. https://stackoverflow.com/questions/5125243/how-can-i-reset-the-ios-simulator-from-the-command-line – N.. Aug 21 '19 at 15:28