How to deal with animation in UITests in iOS
Issue #143
Today I was writing tests and get this error related to app idle
1 | t = 23.06s Assertion Failure: <unknown>:0: Failed to scroll to visible (by AX action) Button, 0x6000003827d0, traits: 8858370049, label: 'cart', error: Error -25204 performing AXAction 2003 on element <XCAccessibilityElement: 0x7fc391a2bd60> pid: 91461, elementOrHash.elementID: 140658975676048.128 |
It turns out that the project uses a HUD that is performing some progress animation. Even it was being called HUD.hide()
, the problem still exists.
1 | t = 31.55s Wait for no.example.MyApp to idle |
No matter how I call sleep,
wait`, still the problem
1 | sleep(10) |
The fix is to disable animation. Start with setting argument when running tests
1 | app.launchArguments.append("--UITests") |
Then in AppDelegate
1 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { |