in FriendlyPixUITests/FriendlyPixUITests.swift [85:123]
func signInWithGoogle() {
let signInButton = win.buttons["Sign in with Google"]
if !signInButton.exists {
signOut()
}
signInButton.tap()
// Enter email or choose account from account chooser.
let email = ProcessInfo.processInfo.environment["GOOGLE_EMAIL"]!
let emailElement = win
.descendants(matching: .any)
.matching(NSPredicate(format: "(label == 'Email or phone') || (label CONTAINS[c] %@)", email))
.element(boundBy: 0)
if !tryToTap(emailElement, forTimeInterval: 3) {
win.tap() // Sometimes need to trigger the permissions dialog first.
}
if emailElement.exists {
emailElement.tap()
}
if emailElement.exists, emailElement.label == "Email or phone" {
emailElement.tap()
emailElement.typeText(email)
win.tap()
tryToTap(win.buttons["Next"], forTimeInterval: 3)
}
// Enter the password field if the user is signed out.
let password = ProcessInfo.processInfo.environment["GOOGLE_PASSWORD"]!
let passwordField = win.secureTextFields["Enter your password"]
if tryToTap(passwordField, forTimeInterval: 3) {
passwordField.typeText(password)
win.tap()
tryToTap(win.buttons["Next"], forTimeInterval: 3)
}
if tryToTap(win.buttons["Confirm your recovery email"]) {
win.tap()
}
}