Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Testing #1529

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 30 additions & 19 deletions Demo/UI Tests/PayPal UI Tests/PayPal_Checkout_UITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Loading