Skip to content

Commit

Permalink
Merge pull request #1538 from Automattic/fix-ui-tests
Browse files Browse the repository at this point in the history
[UI Tests] Handle "Save Password" prompt from iOS.
  • Loading branch information
pachlava authored Nov 6, 2023
2 parents 71b74d6 + c5f6367 commit bddc0bb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Simplenote.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Automattic/XCUITestHelpers",
"state" : {
"revision" : "2cf059427b0f0362ddd8c14109493141cf710cc8",
"version" : "0.2.0"
"revision" : "5179cb69d58b90761cc713bdee7740c4889d3295",
"version" : "0.4.0"
}
}
],
Expand Down
14 changes: 14 additions & 0 deletions SimplenoteUITests/EmailLogin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import XCTest
class EmailLogin {

class func open() {
app.buttons[UID.Button.logIn].waitForIsHittable()
app.buttons[UID.Button.logIn].tap()

app.buttons[UID.Button.logInWithEmail].waitForIsHittable()
app.buttons[UID.Button.logInWithEmail].tap()
}

Expand All @@ -12,6 +15,7 @@ class EmailLogin {
guard backButton.isHittable else { return }

backButton.tap()
handleSavePasswordPrompt()
}

class func logIn() {
Expand All @@ -33,6 +37,7 @@ class EmailLogin {
enterEmail(enteredValue: email)
enterPassword(enteredValue: password)
app.buttons[UID.Button.logIn].tap()
handleSavePasswordPrompt()
}

class func enterEmail(enteredValue: String) {
Expand All @@ -46,4 +51,13 @@ class EmailLogin {
field.tap()
field.typeText(enteredValue)
}

class func handleSavePasswordPrompt() {
// As of Xcode 14.3, the Simulator might ask to save the password which, of course, we don't want to do.
if app.buttons["Save Password"].waitForExistence(timeout: 5) {
// There should be no need to wait for this button to exist since it's part of the same
// alert where "Save Password" is.
app.buttons["Not Now"].tap()
}
}
}

0 comments on commit bddc0bb

Please sign in to comment.