diff --git a/Demo/UI Tests/PayPal UI Tests/PayPal_Checkout_UITests.swift b/Demo/UI Tests/PayPal UI Tests/PayPal_Checkout_UITests.swift index bba4fbf6e..ddcb04d04 100644 --- a/Demo/UI Tests/PayPal UI Tests/PayPal_Checkout_UITests.swift +++ b/Demo/UI Tests/PayPal UI Tests/PayPal_Checkout_UITests.swift @@ -14,42 +14,53 @@ class PayPal_Checkout_UITests: XCTestCase { app.launchArguments.append("-Integration:PayPalWebCheckoutViewController") app.launch() + XCTAssertTrue(app.staticTexts["SandboxEnvironmentLabel"].waitForExistence(timeout: 5)) + app.buttons["PayPal Checkout"].tap() - - // Tap "Continue" on alert + springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") waitForAuthDialogAndTapButton(named: "Continue") } private func waitForAuthDialogAndTapButton(named buttonName: String) { - _ = springboard.buttons[buttonName].waitForExistence(timeout: 20.0) - springboard.buttons[buttonName].tap() + let button = springboard.buttons[buttonName] + XCTAssertTrue(button.waitForExistence(timeout: 20.0), + "The \(buttonName) button did not appear within 20 seconds.") + button.tap() } func testPayPal_checkout_receivesNonce() { let webviewElementsQuery = app.webViews.element.otherElements + let proceedLink = webviewElementsQuery.links["Proceed with Sandbox Purchase"] - self.waitForElementToAppear(webviewElementsQuery.links["Proceed with Sandbox Purchase"]) + XCTAssertTrue(proceedLink.waitForExistence(timeout: 30), + "The 'Proceed with Sandbox Purchase' link did not appear in time.") + XCTAssertTrue(proceedLink.isHittable, + "The 'Proceed with Sandbox Purchase' link is not hittable.") + proceedLink.tap() - webviewElementsQuery.links["Proceed with Sandbox Purchase"].forceTapElement() - - XCTAssertTrue(app.buttons["Got a nonce. Tap to make a transaction."].waitForExistence(timeout: 2)) + let nonceButton = app.buttons["Got a nonce. Tap to make a transaction."] + XCTAssertTrue(nonceButton.waitForExistence(timeout: 30), + "The 'Got a nonce. Tap to make a transaction.' button did not appear in time.") } func testPayPal_checkout_cancelsSuccessfully_whenTappingCancelButtonOnPayPalSite() { - let webviewElementsQuery = app.webViews.element.otherElements - self.waitForElementToAppear(webviewElementsQuery.links["Cancel Sandbox Purchase"]) - - webviewElementsQuery.links["Cancel Sandbox Purchase"].forceTapElement() - - XCTAssertTrue(app.buttons["PayPal flow was canceled by the user."].waitForExistence(timeout: 2)) + let cancelLink = app.webViews.element.otherElements.links["Cancel Sandbox Purchase"] + XCTAssertTrue(cancelLink.waitForExistence(timeout: 30)) + XCTAssertTrue(cancelLink.isHittable) + cancelLink.tap() + + let canceledMessageButton = app.buttons["PayPal flow was canceled by the user."] + XCTAssertTrue(canceledMessageButton.waitForExistence(timeout: 30)) } func testPayPal_checkout_cancelsSuccessfully_whenTappingAuthenticationSessionCancelButton() { - self.waitForElementToAppear(app.buttons["Cancel"]) - - app.buttons["Cancel"].forceTapElement() - - XCTAssertTrue(app.buttons["PayPal flow was canceled by the user."].waitForExistence(timeout: 2)) + let cancelButton = app.buttons["Cancel"] + XCTAssertTrue(cancelButton.waitForExistence(timeout: 30)) + XCTAssertTrue(cancelButton.isHittable) + cancelButton.tap() + + let canceledMessageButton = app.buttons["PayPal flow was canceled by the user."] + XCTAssertTrue(canceledMessageButton.waitForExistence(timeout: 30)) } } diff --git a/Demo/UI Tests/ThreeDSecure UI Tests/ThreeDSecure_V2_UITests.swift b/Demo/UI Tests/ThreeDSecure UI Tests/ThreeDSecure_V2_UITests.swift index 33fcc5205..6de260385 100644 --- a/Demo/UI Tests/ThreeDSecure UI Tests/ThreeDSecure_V2_UITests.swift +++ b/Demo/UI Tests/ThreeDSecure UI Tests/ThreeDSecure_V2_UITests.swift @@ -24,7 +24,7 @@ class ThreeDSecure_V2_UITests: XCTestCase { waitForElementToAppear(app.staticTexts["Purchase Authentication"], timeout: .threeDSecureTimeout) - let textField = app.textFields.element(boundBy: 0) + let textField = app.textFields.element(boundBy: 1) waitForElementToBeHittable(textField) textField.forceTapElement() sleep(2) @@ -44,7 +44,7 @@ class ThreeDSecure_V2_UITests: XCTestCase { waitForElementToAppear(app.staticTexts["Purchase Authentication"], timeout: .threeDSecureTimeout) - let textField = app.textFields.element(boundBy: 0) + let textField = app.textFields.element(boundBy: 1) waitForElementToBeHittable(textField) textField.forceTapElement() sleep(2)