Skip to content

Commit

Permalink
Merge pull request wordpress-mobile#21034 from wordpress-mobile/ui-te…
Browse files Browse the repository at this point in the history
…sts-fix-save-password-prompt

[UI Tests] Disable Auto Fill Passwords for UI Tests
  • Loading branch information
jostnes authored Jul 13, 2023
2 parents 31a4b92 + 628f6e9 commit cd712e3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
21 changes: 21 additions & 0 deletions WordPress/UITests/Utils/XCTest+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ extension XCTestCase {
removeBeforeLaunching: Bool = false,
crashOnCoreDataConcurrencyIssues: Bool = true
) {
// To avoid handling 'Save Password' prompts after login.
disableAutoFillPasswords()

// To ensure that the test starts with a new simulator launch each time
app.terminate()
super.setUp()
Expand All @@ -32,6 +35,24 @@ extension XCTestCase {
systemAlertHandler(alertTitle: "“WordPress” Would Like to Access Your Photos", alertButton: alertButtonTitle)
}

public func disableAutoFillPasswords() {
let settings = XCUIApplication(bundleIdentifier: "com.apple.Preferences")
settings.activate()
settings.staticTexts["Passwords"].tap()

let enterPasscodeScreen = XCUIApplication(bundleIdentifier: "com.apple.springboard")
enterPasscodeScreen.secureTextFields["Passcode field"].typeText(" ")
enterPasscodeScreen.buttons["done"].tap()

settings.staticTexts["Password Options"].tap()

let autoFillPasswordsSwitch = settings.switches["AutoFill Passwords"]
if autoFillPasswordsSwitch.value as? String == "1" {
autoFillPasswordsSwitch.tap()
}
settings.terminate()
}

public func takeScreenshotOfFailedTest() {
guard let failuresCount = testRun?.failureCount, failuresCount > 0 else { return }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ public class LoginUsernamePasswordScreen: ScreenObject {
passwordTextField.typeText(password)
}
nextButton.tap()

app.dismissSavePasswordPrompt()
}

private func dismissQuickStartPromptIfNeeded() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public class PasswordScreen: ScreenObject {

passwordTextField.typeText(password)
continueButton.tap()
app.dismissSavePasswordPrompt()
}

@discardableResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public class PrologueScreen: ScreenObject {
public func selectContinue() throws -> GetStartedScreen {
continueButton.tap()

app.dismissSavePasswordPrompt()

return try GetStartedScreen()
}

Expand Down

0 comments on commit cd712e3

Please sign in to comment.