title: XCtest UI testing - running test stalls on wait for app to idle
body: <p>I'm have just starting using <strong>XCTest</strong> for UI testing.<br>
  While running my tests, execution takes forever.</p>
  
  <p>I get following output:</p>
  
  <pre><code>Wait for app to idle - waits 120 seconds to fail
      App animations complete notification not received, will attempt to continue.
  </code></pre>
  
  <p>I have looked all over and found zero answer on how to either change the timeout or how to manipulate the app to move on.</p>
  
  <p>There are no animations running at all in the app.  The screen is fully loaded.  My developers also have zero answers as well and I have tried disabling animations which fails the tests outright.  </p>
  
  <p>Any ideas on how I can address this?  </p>
  
  <pre><code> func testHomeScreen() {
          logIn()
  
          let home = app.navigationBars["HOME"].staticTexts["HOME"]
          waitForElementToAppear(element: home)
          XCTAssert(home.exists)
  
          let myFriendsButton = app.buttons["My Friends"]
          XCTAssert(myFriendsButton.exists)
  
          let collectionViewsQuery = app.collectionViews
          collectionViewsQuery.buttons["compose"].tap()
          app.navigationBars["CREATE POST"].buttons["CANCEL"].tap()
          collectionViewsQuery.buttons["photo"].tap()
          app.navigationBars["PHOTO BOOTH"].buttons["CANCEL"].tap()
  
          let element = collectionViewsQuery.children(matching: .cell).element(boundBy: 1).children(matching: .other).element
          element.children(matching: .other).element(boundBy: 0).children(matching: .image).element(boundBy: 0).tap()
  
          let profileCloseButton = app.buttons["profile close"]
          profileCloseButton.tap()
  
          let image = element.children(matching: .image).element
          image.swipeUp()
  
          let button = app.navigationBars["DETAILS"].buttons[" "]
  
          let cell = collectionViewsQuery.children(matching: .cell).element(boundBy: 0)
          cell.buttons["actionsheet"].tap()
          app.sheets.buttons["Cancel"].tap()
          cell.buttons["comment"].tap()
          button.tap()
          collectionViewsQuery.buttons["like selected"].tap()
  </code></pre>
  
  <p>Here is my LogIn func and Setup. </p>
  
  <p>func logIn() {
      let app = XCUIApplication()</p>
  
  <pre><code>if  app.tabBars.buttons["HOME"].exists {
      logOut()
  }
  let logInButton = app.buttons["LOG IN"]
  logInButton.tap()
  
  let elementsQuery = app.scrollViews.otherElements
  let emailField = elementsQuery.textFields["example@email.com"]
  emailField.tap()
  emailField.typeText("***************")
  
  let passwordSecureTextField = elementsQuery.secureTextFields["Password"]
  passwordSecureTextField.tap()
  passwordSecureTextField.typeText("************")
  
  app.navigationBars["LOG IN"].buttons["btn login"].tap()
  
  if app.staticTexts["PLEASE TURN ON NOTIFICATIONS"].exists {
      XCTAssert(app.staticTexts["This way you will be able to see when your friends post, message, like or comment on your stuff!"].exists)
      app.buttons["NOT NOW"].tap()
  
  }
  
  if app.collectionViews.staticTexts["3D Rooms Now Available!"].exists {
      XCTAssert(app.collectionViews.staticTexts["Chat with friends in 3D rooms wherever you go! Tap here to get started"].exists)
      app.collectionViews.buttons["close"].tap()
  }
  
  
  if app.staticTexts["DAILY"].exists {
      XCTAssert(app.staticTexts[" SPIN"].exists)
      app.buttons["close"].tap()
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Setup:</p>
  
  <p>class HomeScreenTests: XCTestCase {
      let app = XCUIApplication()</p>
  
  <pre><code>override func setUp() {
      super.setUp()
  
      // Put setup code here. This method is called before the invocation of each test method in the class.
  
      // In UI tests it is usually best to stop immediately when a failure occurs.
      continueAfterFailure = false
      // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
      app.launch()
  
  
      // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
  }
  </code></pre>
  
  <p>Here is a chunk of the output from the test logs:</p>
  
  <p><a href="https://i.stack.imgur.com/sVLjI.png" rel="nofollow noreferrer">LogFile</a></p>