mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 20:09:04 +00:00
Fix XCUITest text entry on all paths
This commit is contained in:
@@ -14,7 +14,10 @@ extension XCUIElement {
|
|||||||
///
|
///
|
||||||
/// Keystrokes are silently dropped when the element hasn't finished taking focus, which corrupts the
|
/// Keystrokes are silently dropped when the element hasn't finished taking focus, which corrupts the
|
||||||
/// value in ways that are hard to spot later on, so the result is verified and retried before failing.
|
/// value in ways that are hard to spot later on, so the result is verified and retried before failing.
|
||||||
func clearAndTypeText(_ text: String, app: XCUIApplication) {
|
///
|
||||||
|
/// - Parameter verifyingValue: Whether to read the value back. Pass `false` for a field that submits
|
||||||
|
/// itself once it is full, such as the PIN screens, as its value can no longer be read at that point.
|
||||||
|
func clearAndTypeText(_ text: String, app: XCUIApplication, verifyingValue: Bool = true) {
|
||||||
for _ in 0..<3 {
|
for _ in 0..<3 {
|
||||||
tap(.center)
|
tap(.center)
|
||||||
|
|
||||||
@@ -33,7 +36,7 @@ extension XCUIElement {
|
|||||||
typeText(text)
|
typeText(text)
|
||||||
|
|
||||||
// A newline submits the field, which tears it down before its value can be read back.
|
// A newline submits the field, which tears it down before its value can be read back.
|
||||||
if text.contains("\n") || containsTypedText(text) {
|
if text.contains("\n") || !verifyingValue || containsTypedText(text) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,13 +148,13 @@ class AppLockSetupUITests: XCTestCase {
|
|||||||
let textField = app.secureTextFields[A11yIdentifiers.appLockSetupPINScreen.textField]
|
let textField = app.secureTextFields[A11yIdentifiers.appLockSetupPINScreen.textField]
|
||||||
XCTAssert(textField.waitForExistence(timeout: 10))
|
XCTAssert(textField.waitForExistence(timeout: 10))
|
||||||
|
|
||||||
textField.clearAndTypeText("2023", app: app)
|
textField.clearAndTypeText("2023", app: app, verifyingValue: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func enterDifferentPIN() {
|
private func enterDifferentPIN() {
|
||||||
let textField = app.secureTextFields[A11yIdentifiers.appLockSetupPINScreen.textField]
|
let textField = app.secureTextFields[A11yIdentifiers.appLockSetupPINScreen.textField]
|
||||||
XCTAssert(textField.waitForExistence(timeout: 10))
|
XCTAssert(textField.waitForExistence(timeout: 10))
|
||||||
|
|
||||||
textField.clearAndTypeText("2233", app: app)
|
textField.clearAndTypeText("2233", app: app, verifyingValue: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user