Skip to content

Commit 61b515e

Browse files
authored
Merge pull request #4036 from wmathurin/master
Update LoginPageObject for login screen changes.
2 parents 64799cd + e816664 commit 61b515e

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

native/SampleApps/AuthFlowTester/AuthFlowTesterUITests/PageObjects/LoginPageObject.swift

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,18 @@ class LoginPageObject {
8181
func performLogin(username: String, password: String) {
8282
setTextField(usernameField(), value: username)
8383
dismissKeyboardAfterTyping()
84+
tap(loginButton())
8485
setTextField(passwordField(), value: password)
8586
dismissKeyboardAfterTyping()
8687
tap(loginButton())
8788
tapIfPresent(allowButton())
8889
}
8990

9091
func performAdvancedLogin(username: String, password: String) {
91-
// Fill password first so username field remains visible above the keyboard
92-
tap(passwordField())
93-
setTextField(passwordField(), value: password)
94-
// Now tap username field (visible above keyboard) and fill it
95-
tap(usernameField())
9692
setTextField(usernameField(), value: username)
97-
// Press Return to submit the form
9893
usernameField().typeText(XCUIKeyboardKey.return.rawValue)
94+
setTextField(passwordField(), value: password)
95+
passwordField().typeText(XCUIKeyboardKey.return.rawValue)
9996
tapIfPresent(allowButton())
10097
}
10198

@@ -120,8 +117,9 @@ class LoginPageObject {
120117
}
121118

122119
func performWelcomeLogin(password: String) {
120+
tap(loginButton())
123121
setTextField(passwordField(), value: password)
124-
tap(usernameFieldLabel()) // click on label to hide keyboard
122+
dismissKeyboardAfterTyping()
125123
tap(loginButton())
126124
tapIfPresent(allowButton())
127125
}
@@ -199,10 +197,15 @@ class LoginPageObject {
199197

200198
/// Dismisses the keyboard after typing in a field. Tries the toolbar "Done" button first;
201199
/// if not found (e.g. on some simulators it is exposed as a Key, not Button), taps the
202-
/// password label to dismiss.
200+
/// password label or username label to dismiss.
203201
private func dismissKeyboardAfterTyping() {
204202
if !tapIfPresent(toolbarDoneButton()) {
205-
tap(passwordFieldLabel())
203+
let passwordLabel = passwordFieldLabel()
204+
if passwordLabel.exists {
205+
passwordLabel.tap()
206+
} else {
207+
tap(usernameFieldLabel())
208+
}
206209
}
207210
}
208211

0 commit comments

Comments
 (0)