diff --git a/ElementX/Sources/Other/Extensions/XCUIElement.swift b/ElementX/Sources/Other/Extensions/XCUIElement.swift index 347b7528b..b3c5db6ba 100644 --- a/ElementX/Sources/Other/Extensions/XCUIElement.swift +++ b/ElementX/Sources/Other/Extensions/XCUIElement.swift @@ -37,7 +37,7 @@ extension XCUIElement { if isHittable { tap() } else { - let coordinate: XCUICoordinate = coordinate(withNormalizedOffset: .init(dx: 0.0, dy: 0.0)) + let coordinate: XCUICoordinate = coordinate(withNormalizedOffset: .init(dx: 0.5, dy: 0.5)) coordinate.tap() } } diff --git a/IntegrationTests/Sources/Common.swift b/IntegrationTests/Sources/Common.swift index 42a37a4b2..2b1a0821e 100644 --- a/IntegrationTests/Sources/Common.swift +++ b/IntegrationTests/Sources/Common.swift @@ -36,8 +36,9 @@ extension XCUIApplication { XCTAssertTrue(confirmButton.waitForExistence(timeout: 10.0)) confirmButton.tap() + // Server cofirmation is network bound and might take a while let continueButton = buttons[A11yIdentifiers.serverConfirmationScreen.continue] - XCTAssertTrue(continueButton.waitForExistence(timeout: 10.0)) + XCTAssertTrue(continueButton.waitForExistence(timeout: 30.0)) continueButton.tap() let usernameTextField = textFields[A11yIdentifiers.loginScreen.emailUsername] @@ -56,10 +57,13 @@ extension XCUIApplication { nextButton.tap() - sleep(10) + // Wait for login to finish + let doesNotExistPredicate = NSPredicate(format: "exists == 0") + currentTestCase.expectation(for: doesNotExistPredicate, evaluatedWith: usernameTextField) + currentTestCase.waitForExpectations(timeout: 300.0) // Handle analytics prompt screen - if staticTexts[A11yIdentifiers.analyticsPromptScreen.title].waitForExistence(timeout: 1.0) { + if staticTexts[A11yIdentifiers.analyticsPromptScreen.title].waitForExistence(timeout: 10.0) { // Wait for login and then handle save password sheet let savePasswordButton = buttons["Save Password"] if savePasswordButton.waitForExistence(timeout: 10.0) { @@ -79,9 +83,9 @@ extension XCUIApplication { // Handle the notifications permission alert https://stackoverflow.com/a/58171074/730924 let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") - let alertAllowButton = springboard.buttons.element(boundBy: 1) - if alertAllowButton.waitForExistence(timeout: 10.0) { - alertAllowButton.tap() + let notificationAlertDeclineButton = springboard.buttons.element(boundBy: 0) + if notificationAlertDeclineButton.waitForExistence(timeout: 10.0) { + notificationAlertDeclineButton.tap() } // Migration screen may be shown as an overlay. @@ -108,8 +112,12 @@ extension XCUIApplication { } func logout() { - let profileButton = buttons[A11yIdentifiers.homeScreen.userAvatar] + // On first login when multiple sheets get presented the profile button is not hittable + // Moving the scroll fixed it for some obscure reason + swipeDown() + let profileButton = buttons[A11yIdentifiers.homeScreen.userAvatar] + // `Failed to scroll to visible (by AX action) Button` https://stackoverflow.com/a/33534187/730924 profileButton.forceTap() diff --git a/IntegrationTests/Sources/UserFlowTests.swift b/IntegrationTests/Sources/UserFlowTests.swift index 28191c3e0..6e447ca5d 100644 --- a/IntegrationTests/Sources/UserFlowTests.swift +++ b/IntegrationTests/Sources/UserFlowTests.swift @@ -75,6 +75,8 @@ class UserFlowTests: XCTestCase { // Cancel the upload flow tapOnButton("Cancel") + + sleep(2) // Wait for dismissal } private func checkRoomCreation() { @@ -90,7 +92,7 @@ class UserFlowTests: XCTestCase { tapOnButton("Cancel") - sleep(1) + sleep(2) // Wait for dismissal } private func checkTimelineItemActionMenu() { @@ -114,9 +116,9 @@ class UserFlowTests: XCTestCase { // Open the room member details tapOnButton(A11yIdentifiers.roomDetailsScreen.people) - // Open the first member's details + // Open the first member's details. Loading members for big rooms can take a while. let firstRoomMember = app.scrollViews.buttons.firstMatch - XCTAssertTrue(firstRoomMember.waitForExistence(timeout: 10.0)) + XCTAssertTrue(firstRoomMember.waitForExistence(timeout: 300.0)) firstRoomMember.tap() // Go back to the room member details @@ -133,6 +135,10 @@ class UserFlowTests: XCTestCase { } private func checkSettings() { + // On first login when multiple sheets get presented the profile button is not hittable + // Moving the scroll fixed it for some obscure reason + app.swipeDown() + let profileButton = app.buttons[A11yIdentifiers.homeScreen.userAvatar] // `Failed to scroll to visible (by AX action) Button` https://stackoverflow.com/a/33534187/730924