XCTest: Disable animations on iOS Safari browser

58 Views Asked by At

I am working on XCUITest to automate some features in Safari browser in iPhone. Intermittently, I am seeing following logs and automation is stuck.

t =   504.16s         Wait for app to idle
t =   625.29s         App animations complete notification not received, will attempt to continue.
t =   625.30s         Synthesize event
t =   625.67s         Wait for app to idle

All the answers on internet suggest to use UIView.setAnimationsEnabled(false). I tried this solution, but this has not helped much.

My question is: Does UIView.setAnimationsEnabled(false) disable the animations only in apps or will this also be applicable for websites in Safari browser? If not, are there any other workarounds?

Ref - Xcode 8 UI Testing Taking Very Long

1

There are 1 best solutions below

0
On

Found the answer in Disabling waiting for idle state in UI testing of iOS apps. TestBase is my base class extended from XCTestCase

private func disableWaitForIdle() {
    if !TestBase.swizzledOutIdle {
        let original = class_getInstanceMethod(objc_getClass("XCUIApplicationProcess") as? AnyClass, Selector(("waitForQuiescenceIncludingAnimationsIdle:")))
        let replaced = class_getInstanceMethod(type(of: self), #selector(TestBase.replace))!
        method_exchangeImplementations(original!, replaced)
        TestBase.swizzledOutIdle = true
    }
}

@objc func replace() {
    return
}

Usage:

override func setUp() {
        Self.logger.info("Running test method setup before \(self.name)...")
        disableWaitForIdle()
        super.setUp()
        continueAfterFailure = false
        UIView.setAnimationsEnabled(false)
}