Refactor iOS UI tests to blueprint architecture
This commit is contained in:
@@ -5,6 +5,7 @@ struct UITestID {
|
||||
static let ready = "ui.app.ready"
|
||||
static let onboarding = "ui.root.onboarding"
|
||||
static let login = "ui.root.login"
|
||||
static let mainTabs = "ui.root.mainTabs"
|
||||
}
|
||||
|
||||
struct Onboarding {
|
||||
@@ -88,7 +89,12 @@ struct OnboardingWelcomeScreen {
|
||||
}
|
||||
|
||||
func tapAlreadyHaveAccount() {
|
||||
loginButton.waitUntilHittable(timeout: 10).tap()
|
||||
loginButton.waitForExistenceOrFail(timeout: 10)
|
||||
if loginButton.isHittable {
|
||||
loginButton.tap()
|
||||
} else {
|
||||
loginButton.forceTap()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,20 +230,44 @@ struct RegisterScreen {
|
||||
}
|
||||
|
||||
func fill(username: String, email: String, password: String) {
|
||||
func advanceToNextField() {
|
||||
let keys = ["Next", "Return", "return", "Done", "done"]
|
||||
for key in keys {
|
||||
let button = app.keyboards.buttons[key]
|
||||
if button.waitForExistence(timeout: 1) && button.isHittable {
|
||||
button.tap()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
usernameField.waitForExistenceOrFail(timeout: 10)
|
||||
usernameField.forceTap()
|
||||
usernameField.typeText(username)
|
||||
advanceToNextField()
|
||||
|
||||
emailField.waitForExistenceOrFail(timeout: 10)
|
||||
emailField.forceTap()
|
||||
if !emailField.hasKeyboardFocus {
|
||||
emailField.forceTap()
|
||||
if !emailField.hasKeyboardFocus {
|
||||
advanceToNextField()
|
||||
emailField.forceTap()
|
||||
}
|
||||
}
|
||||
emailField.typeText(email)
|
||||
advanceToNextField()
|
||||
|
||||
passwordField.waitForExistenceOrFail(timeout: 10)
|
||||
passwordField.forceTap()
|
||||
if !passwordField.hasKeyboardFocus {
|
||||
passwordField.forceTap()
|
||||
}
|
||||
passwordField.typeText(password)
|
||||
advanceToNextField()
|
||||
|
||||
confirmPasswordField.waitForExistenceOrFail(timeout: 10)
|
||||
confirmPasswordField.forceTap()
|
||||
if !confirmPasswordField.hasKeyboardFocus {
|
||||
confirmPasswordField.forceTap()
|
||||
}
|
||||
confirmPasswordField.typeText(password)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user