diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerAppFixtures.m b/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerAppFixtures.m index 901d18573c..6017f73888 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerAppFixtures.m +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerAppFixtures.m @@ -45,6 +45,7 @@ @interface AgentDeviceRunnerFixtureViewController () +// Shows how many deletes and taps the field received. +@property(nonatomic, weak) UILabel *countLabel; +// Refuses the first focus, as a field whose first tap the app consumes does. +@property(nonatomic, assign) BOOL refusesFirstFocus; +// Reports the placeholder as the value while empty, as a React Native secure input does. +@property(nonatomic, assign) BOOL reportsPlaceholderAsValue; +@end + @interface AgentDeviceValueReadCountLabel : UILabel @property(nonatomic, weak) UITextField *countedField; @end diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunner/UnitTests/AgentDeviceTextEntryFields.m b/apple/runner/AgentDeviceRunner/AgentDeviceRunner/UnitTests/AgentDeviceTextEntryFields.m index 81544e0244..1038c35d9d 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunner/UnitTests/AgentDeviceTextEntryFields.m +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunner/UnitTests/AgentDeviceTextEntryFields.m @@ -12,6 +12,59 @@ - (NSString *)accessibilityValue { } @end +@implementation AgentDeviceSecureEntryField { + NSUInteger _deletes; + NSUInteger _taps; +} +- (instancetype)init { + self = [super init]; + if (self) { + UITapGestureRecognizer *tapCounter = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(countTap:)]; + tapCounter.cancelsTouchesInView = NO; + tapCounter.delegate = self; + [self addGestureRecognizer:tapCounter]; + } + return self; +} + +- (void)countTap:(UITapGestureRecognizer *)recognizer { + (void)recognizer; + _taps += 1; + [self showCounts]; +} + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { + (void)gestureRecognizer; + (void)otherGestureRecognizer; + return YES; +} + +- (void)showCounts { + self.countLabel.text = [NSString stringWithFormat:@"deletes=%lu taps=%lu", (unsigned long)_deletes, (unsigned long)_taps]; +} + +- (BOOL)becomeFirstResponder { + if (self.refusesFirstFocus) { + self.refusesFirstFocus = NO; + return NO; + } + return [super becomeFirstResponder]; +} + +- (void)deleteBackward { + _deletes += 1; + [self showCounts]; + [super deleteBackward]; +} + +- (NSString *)accessibilityValue { + if (self.reportsPlaceholderAsValue && self.text.length == 0) { + return self.placeholder; + } + return [super accessibilityValue]; +} +@end + static NSUInteger AgentDeviceTextEntryValueReads = 0; @implementation AgentDeviceValueReadCountingTextField diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift index ca8ec50d42..f7d1e4b878 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift @@ -395,10 +395,10 @@ extension RunnerTests { /// Clears the reader's input. Every post goes through `reader.dispatch` and every read back through /// `reader.input()`, so a bound target's clear stops at an input that took its place. On iOS a - /// readable value is selected whole and deleted, wherever the caret is. Otherwise, or when text is - /// left, delete bursts run from the caret, and a value longer than one burst is read again after - /// each burst until it reads empty, stops shortening, or has had at least one burst more than it - /// needs. + /// readable value is selected whole and deleted, wherever the caret is, and a masked value gets + /// deletes before any caret tap. Otherwise, or when text is left, delete bursts run from the caret, + /// and a value longer than one burst is read again after each burst until it reads empty, stops + /// shortening, or has had at least one burst more than it needs. func clearTextInput(app: XCUIApplication, reader: inout TextEntryReader) throws { guard let input = try reader.input() else { return @@ -408,15 +408,44 @@ extension RunnerTests { // be stale after the field repositions on focus (e.g. the Settings search bar jumps // bottom->top and reveals a "Suggestions" list) — tapping there navigates away instead of // clearing; and replacing into an already-empty field is a no-op anyway. - // editableTextValue returns nil for secure (and unknown) fields, where we CANNOT confirm - // emptiness — those must still be cleared, or replace would concatenate stale + new text. - // So distinguish nil (clear) from "" (skip). - let existing = editableTextValue(for: input.attributes, treatingPlaceholderAsEmpty: true) + // textValueForClear returns nil for secure (and unknown) fields, and for a placeholder that is + // itself a mask, where we CANNOT confirm emptiness — those must still be cleared, or + // replace would concatenate stale + new text. So distinguish nil (clear) from "" (skip). On iOS + // the masked route below can still prove a masked field empty. + let existing = textValueForClear(input.attributes) if existing?.isEmpty == true { return } let defersCaretTap = reader.target.reusesCurrentFocus var valueLength = normalizedElementText(input.attributes.value).count +#if os(iOS) + // A masked value cannot aim the caret tap, which lands at the field's right edge, where an app + // often draws a show/hide control: pressing it swaps the input (tester-army/e2e#1631). iOS clears + // a secure field on its first delete after the field takes focus, and deletes from a caret left + // at the end reach the rest, so deletes go first and the caret moves only for masked text left. + if textValueRead(for: input.attributes) == .unreadable { + // Deletes or text sent to a field without focus record an XCTest failure, which tears down the + // runner. The focus step can leave focus unconfirmed, so the field gets the readiness repeat at + // its center, clear of a control at the edge, even when it is empty and needs no clear. + if input.snapshot.map({ snapshotHasKeyboardFocus($0) }) != true { + try reader.dispatch { try retapAt(read: input, app: app, element: input.element) } + } + if maskedTextShown(by: input) == .empty { + NSLog("AGENT_DEVICE_RUNNER_TEXT_ENTRY_CLEAR route=masked-skip shown=empty") + return + } + let burst = Self.textClearBurst(valueLength: valueLength) + reader.dispatch { input.element.typeText(String(repeating: XCUIKeyboardKey.delete.rawValue, count: burst)) } + // An input that stops answering (#3060) goes on to the caret tap and burst below. + if let cleared = try reader.input() { + let shown = maskedTextShown(by: cleared) + NSLog("AGENT_DEVICE_RUNNER_TEXT_ENTRY_CLEAR route=masked-deletes shown=%@", String(describing: shown)) + if shown != .text { + return + } + } + } +#endif // The tap also focuses the field, which a clear can reach with focus unconfirmed. #if !os(tvOS) if !defersCaretTap { @@ -513,6 +542,33 @@ extension RunnerTests { remainingLength > 0 && remainingLength < clearedLength } + /// What a masked field shows about its text. + enum MaskedTextShown: Equatable { + /// No text, or a placeholder that is not itself a mask: the field is empty. + case empty + /// A placeholder that is itself a mask, which text of the same length shows too. + case maskPlaceholder + /// Anything else, such as a mask other than the placeholder: text may be in the field. + case text + } + + static func maskedTextShown(value: String, showsPlaceholder: Bool) -> MaskedTextShown { + let shown = value.trimmingCharacters(in: .whitespacesAndNewlines) + if shown.isEmpty { + return .empty + } + if showsPlaceholder { + return isMaskedTextValue(shown) ? .maskPlaceholder : .empty + } + return .text + } + + /// `maskedTextShown(value:showsPlaceholder:)` for `input`, with the placeholder rule the shared read uses. + func maskedTextShown(by input: ResolvedTextEntryInput) -> MaskedTextShown { + let value = normalizedElementText(input.attributes.value) + return Self.maskedTextShown(value: value, showsPlaceholder: isPlaceholderValue(value, for: input.attributes)) + } + func isTextEntryElement(_ element: XCUIElement) -> Bool { switch element.elementType { case .textField, .secureTextField, .searchField, .textView: @@ -749,6 +805,20 @@ extension RunnerTests { return value } + /// The text a clear can trust in the input `attributes` describe, with a placeholder read as empty; + /// nil when unreadable. A placeholder that is itself a mask is nil too, since text of its length shows + /// it as well, so that field is cleared instead of skipped. Only the clear reads it this way: the + /// shared read keeps such a placeholder empty for verification, as a PIN field that shows its digits needs. + func textValueForClear(_ attributes: (any XCUIElementAttributes)?) -> String? { + guard let value = editableTextValue(for: attributes, treatingPlaceholderAsEmpty: true) else { + return nil + } + if value.isEmpty, Self.isMaskedTextValue(normalizedElementText(attributes?.value)) { + return nil + } + return value + } + /// Whether an accessibility value is a masked rendering of a secure field: one or more /// password bullets and nothing else. The bullet count need not match the typed length, so /// such a value carries no information about what the field holds. A field whose real text is diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift index 4ec331f5a0..21a5a0f617 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift @@ -123,7 +123,7 @@ extension RunnerTests { logTextEntryPhase(commandId: commandId, phase: "total", startedAt: totalStartedAt, chars: text.count, mode: repairMode) return TextEntryResult(verified: nil, repaired: false, expectedText: expectedText, observedText: nil) } - if currentText == nil || currentText?.isEmpty == false { + if textValueForClear(initialTarget?.attributes)?.isEmpty != true { let clearStartedAt = Date() try clearTextInput(app: app, reader: &reader) logTextEntryPhase( diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextEntryPolicyTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextEntryPolicyTests.swift index b5d7726509..96cf147896 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextEntryPolicyTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextEntryPolicyTests.swift @@ -141,6 +141,18 @@ extension RunnerTests { XCTAssertFalse(Self.textClearContinues(clearedLength: 501, remainingLength: 640)) } + // A secure field shows its placeholder when empty and a mask otherwise. A placeholder that is not a + // mask proves it empty; one that is itself a mask proves nothing, since text of its length shows it + // too (tester-army/e2e#1631). + func testMaskedTextShownTellsAnEmptyFieldFromAMaskPlaceholder() { + let bullets = { (count: Int) in String(repeating: "\u{2022}", count: count) } + XCTAssertEqual(Self.maskedTextShown(value: "", showsPlaceholder: false), .empty) + XCTAssertEqual(Self.maskedTextShown(value: "Password", showsPlaceholder: true), .empty) + XCTAssertEqual(Self.maskedTextShown(value: bullets(8), showsPlaceholder: true), .maskPlaceholder) + XCTAssertEqual(Self.maskedTextShown(value: bullets(3), showsPlaceholder: false), .text) + XCTAssertEqual(Self.maskedTextShown(value: "hunter2", showsPlaceholder: false), .text) + } + // One read owns readability for every route: a secure field is unreadable whatever it reports, // a plain field is unreadable only while its value is a mask, and anything that is not a text // input has no text to read. diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift index e692526a79..b5709a0428 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift @@ -580,6 +580,196 @@ extension RunnerTests { XCTAssertEqual(togglePresses.label, "presses=0") } + // A masked value cannot aim the clear's caret tap, which lands on a show/hide toggle at the field's + // right edge; in React Native the press swaps the input and the fill fails (tester-army/e2e#1631). + // The fixture's masked field shows one bullet per two characters, so 8 bullets is the new text alone. + @MainActor + func testFillReplacesAPrefilledMaskedValueWithoutPressingItsEdgeToggle() throws { + try assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: ["--agent-device-text-entry-masked-value", "--agent-device-text-entry-prefilled"], + field: { $0.textFields }, + expectedValue: String(repeating: "\u{2022}", count: 8) + ) + } + + @MainActor + func testFillReplacesAPrefilledSecureFieldWithoutPressingItsEdgeToggle() throws { + try assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: ["--agent-device-text-entry-secure-entry", "--agent-device-text-entry-prefilled"], + field: { $0.secureTextFields }, + expectedValue: String(repeating: "\u{2022}", count: 16) + ) + } + + // An empty secure field with no placeholder shows nothing, so nothing is cleared. + @MainActor + func testFirstFillIntoAnEmptySecureFieldSkipsTheClear() throws { + try assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: ["--agent-device-text-entry-secure-entry"], + field: { $0.secureTextFields }, + expectedValue: String(repeating: "\u{2022}", count: 16) + ) + XCTAssertEqual(try secureEntryCounts().deletes, 0) + } + + // A field that refuses the focus tap reaches the clear without focus, and deletes sent to it record + // an XCTest failure. The clear focuses it at its center first. + @MainActor + func testFillReplacesTextInASecureFieldThatRefusedTheFocusTap() throws { + try assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: [ + "--agent-device-text-entry-secure-entry", + "--agent-device-text-entry-prefilled", + "--agent-device-text-entry-refuses-first-focus", + ], + field: { $0.secureTextFields }, + expectedValue: String(repeating: "\u{2022}", count: 16) + ) + } + + // An empty one needs no clear, but the text typed next needs focus just as the deletes do. + @MainActor + func testFirstFillIntoAnEmptySecureFieldThatRefusedTheFocusTap() throws { + try assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: ["--agent-device-text-entry-secure-entry", "--agent-device-text-entry-refuses-first-focus"], + field: { $0.secureTextFields }, + expectedValue: String(repeating: "\u{2022}", count: 16) + ) + XCTAssertEqual(try secureEntryCounts().deletes, 0) + } + + // Deletes from a caret moved to the start reach none of the text, so the clear falls back to the caret + // tap at the right edge, which in this fixture lands on the toggle. + @MainActor + func testMaskedTextTheDeletesCannotReachFallsBackToTheCaretTap() throws { + app.launchArguments = [ + "--agent-device-text-entry-regression", + "--agent-device-text-entry-soft-keyboard", + "--agent-device-text-entry-masked-value", + "--agent-device-text-entry-prefilled", + ] + app.launch() + addTeardownBlock { [self] in + invalidateCachedTarget(reason: "unit_test_cleanup") + app.terminate() + } + let input = app.textFields["agent-device-hardware-keyboard-input"] + XCTAssertTrue(input.waitForFixtureExistence(timeout: appExistenceTimeout)) + let togglePresses = app.staticTexts["agent-device-masked-toggle-presses"] + XCTAssertTrue(togglePresses.waitForFixtureExistence(timeout: appExistenceTimeout)) + input.coordinate(withNormalizedOffset: CGVector(dx: 0.02, dy: 0.5)).tap() + + let response = try executeTypeCommand( + activeApp: app, + command: try fillCommandFixture(commandId: "fill-caret-at-start", text: "abc", at: input) + ) + + XCTAssertTrue(response.ok, String(describing: response.error)) + XCTAssertEqual(togglePresses.label, "presses=1") + } + + // The issue's own case: its placeholder is eight bullets, which React Native reports as the value of + // the empty field. + @MainActor + func testFirstFillIntoASecureFieldShowingABulletPlaceholderDoesNotPressItsEdgeToggle() throws { + try assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: ["--agent-device-text-entry-secure-entry", "--agent-device-text-entry-bullet-placeholder"], + field: { $0.secureTextFields }, + expectedValue: String(repeating: "\u{2022}", count: 16) + ) + } + + // A plain masked field whose eight bullets match its eight-bullet placeholder can't be told from empty + // either, so the refill still clears it. The fixture shows one bullet per two characters, so the 18 + // characters refilled show as 9 bullets, and kept stale text would show as 17. + @MainActor + func testRefillOfAMaskedFieldClearsTextThatReadsLikeItsBulletPlaceholder() throws { + try assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: ["--agent-device-text-entry-masked-value", "--agent-device-text-entry-bullet-placeholder"], + field: { $0.textFields }, + text: "not-a-secret-12345", + expectedValue: String(repeating: "\u{2022}", count: 9), + afterFilling: "abcdefghijklmnop" + ) + } + + // iOS doesn't clear a field that kept its focus on its next edit, and eight characters read the same + // as the eight-bullet placeholder, so the refill must still clear them. It reads the field's focus, + // so it adds no tap to the first fill's one. + @MainActor + func testRefillOfAFocusedSecureFieldClearsTextThatReadsLikeItsBulletPlaceholder() throws { + try assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: ["--agent-device-text-entry-secure-entry", "--agent-device-text-entry-bullet-placeholder"], + field: { $0.secureTextFields }, + expectedValue: String(repeating: "\u{2022}", count: 16), + afterFilling: "stale-pw" + ) + XCTAssertEqual(try secureEntryCounts().taps, 1) + } + + /// Fills `text` the way the daemon sends `fill`, after `earlierText` when given, and checks the field + /// holds the new text alone while the toggle over its right edge stays unpressed. + @MainActor + private func assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: [String], + field: (XCUIApplication) -> XCUIElementQuery, + text: String = "not-a-secret-123", + expectedValue: String, + afterFilling earlierText: String? = nil + ) throws { + app.launchArguments = [ + "--agent-device-text-entry-regression", + "--agent-device-text-entry-soft-keyboard", + ] + launchArguments + app.launch() + addTeardownBlock { [self] in + invalidateCachedTarget(reason: "unit_test_cleanup") + app.terminate() + } + XCTAssertTrue(app.waitForFixtureExistence(timeout: appExistenceTimeout)) + let input = field(app)["agent-device-hardware-keyboard-input"] + XCTAssertTrue(input.waitForFixtureExistence(timeout: appExistenceTimeout)) + let togglePresses = app.staticTexts["agent-device-masked-toggle-presses"] + XCTAssertTrue(togglePresses.waitForFixtureExistence(timeout: appExistenceTimeout)) + XCTAssertEqual(togglePresses.label, "presses=0") + if let earlierText { + // Only the field this fill leaves is the precondition: a result that shows as a bullet placeholder + // reads back as that placeholder, which fill's own check reports as a mismatch. An empty field + // shows that placeholder too, so the app's length witness tells the two apart. + _ = try executeTypeCommand( + activeApp: app, + command: try fillCommandFixture(commandId: "fill-earlier-text", text: earlierText, at: input) + ) + let length = app.staticTexts["agent-device-masked-text-length"] + let filled = XCTNSPredicateExpectation( + predicate: NSPredicate(format: "label == %@", "length=\(earlierText.count)"), + object: length + ) + XCTAssertEqual(XCTWaiter.wait(for: [filled], timeout: appExistenceTimeout), .completed, length.label) + } + + let failureCountBefore = currentXCTestFailureCount() + let response = try executeTypeCommand( + activeApp: app, + command: try fillCommandFixture(commandId: "fill-masked-input-beside-toggle", text: text, at: input) + ) + + XCTAssertTrue(response.ok, String(describing: response.error)) + XCTAssertFalse(didRecordXCTestFailure(since: failureCountBefore)) + let replaced = XCTNSPredicateExpectation(predicate: NSPredicate(format: "value == %@", expectedValue), object: input) + XCTAssertEqual(XCTWaiter.wait(for: [replaced], timeout: appExistenceTimeout), .completed, String(describing: input.value)) + XCTAssertEqual(togglePresses.label, "presses=0") + } + + /// The deletes and taps the secure entry fixture's field received. + @MainActor + private func secureEntryCounts() throws -> (deletes: Int, taps: Int) { + let label = app.staticTexts["agent-device-secure-entry-counts"].label + let counts = try label.split(separator: " ").map { try XCTUnwrap(Int($0.split(separator: "=").last ?? ""), label) } + XCTAssertEqual(counts.count, 2, label) + return (counts.first ?? -1, counts.last ?? -1) + } + private struct UnavailableTextEntrySynthesizer: TextEntrySynthesizing { func enterText( app _: XCUIApplication, diff --git a/src/commands/schema/cli-help-workflows.ts b/src/commands/schema/cli-help-workflows.ts index 38629854c4..29b7ab5114 100644 --- a/src/commands/schema/cli-help-workflows.ts +++ b/src/commands/schema/cli-help-workflows.ts @@ -186,7 +186,7 @@ Stabilizers: Re-enable settings you changed before finishing. Text-entry quirks: - Local iOS fill reuses focus when the current command identifies the target input and reads its keyboard focus. Readable focused inputs use select-all/delete with read-back before any fallback caret tap. + Local iOS fill reuses focus when the current command identifies the target input and reads its keyboard focus. Readable focused inputs use select-all/delete with read-back before any fallback caret tap. Masked inputs, such as secure fields, that show nothing or a placeholder that is not a mask are not cleared; other masked inputs get deletes with read-back before any fallback caret tap. Masked text the deletes can't reach that shows as many bullets as the placeholder reads as cleared, so the new text is typed next to it. iOS Allow Paste cannot be exercised under XCUITest; prefill with clipboard write "some text" instead and test the system prompt manually. Android Gboard handwriting/stylus UI can capture text in an IME-owned input instead of the app field. If fill reports that input was captured by the keyboard/IME, use the diagnostic targetInput/actualInput details, inspect keyboard status/get if needed, and switch or disable handwriting outside the command plan before retrying. Do not keep retrying fill/type against the same field while the IME owns focus. If the exact target changes but app-owned formatting prevents raw equality, fill succeeds with verification: "unconfirmed" plus target-bound requested/before/after evidence; inspect that evidence instead of retrying the same mutation. iOS accessibility-driven fill types the replacement once and never clears and retypes a read-back mismatch. Exact settled text confirms the entry. Nonempty replacements wait until the confirmation deadline before reporting TEXT_ENTRY_MISMATCH. A value containing only characters in order from the post-clear value plus the request fails with TEXT_ENTRY_MISMATCH, including plain dropped characters and unchanged values; legitimate trimming or masks can also hit this limit ("5" into "$0.00" displaying "$0.05"). Other settled values return verification: "unconfirmed" with requested/before/after/target evidence, including grouping ("00 062 91 77" for "000629177"), currency ("$10.00" for "1000"), and OTP summaries. Missing, reordered, duplicated or stale text can also be unconfirmed, so assert the expected value with a value selector, get/is, or the resulting screen before continuing. For single-line fills ending in a submit key, any non-matching value observed on the same target succeeds unverified, including partial or cleared text; this exception skips dropped-character checks because the submit may change the field. Assert the resulting screen. Multiline fields compare newlines as content. Unreadable or removed fields remain unverified. The coordinate-driven fill route still requires an exact match. After TEXT_ENTRY_MISMATCH, inspect the field and retry fill only if it needs correction, using the --delay-ms value from the error hint. diff --git a/website/docs/docs/commands.md b/website/docs/docs/commands.md index fa5c560ad0..7441151dd0 100644 --- a/website/docs/docs/commands.md +++ b/website/docs/docs/commands.md @@ -497,7 +497,7 @@ A `click` or `press` whose target the daemon resolves to a point (`@ref` or sele ### Text entry - `fill` replaces the field value. `type` appends to the focused field and accepts text only: use `fill @ref "text"` to target a field, or `press @ref` then `type "text"`. -- iOS, including Limrun, `fill` avoids another focus tap when the current command identifies the target input and reads its keyboard focus. For readable focused inputs, clearing tries select-all/delete and reads the result before moving the caret for delete-burst fallback. Newly focused inputs retain caret preparation. +- iOS, including Limrun, `fill` avoids another focus tap when the current command identifies the target input and reads its keyboard focus. For readable focused inputs, clearing tries select-all/delete and reads the result before moving the caret for delete-burst fallback. Newly focused inputs retain caret preparation. A masked input, such as a secure field, is not cleared when it shows nothing or a placeholder that is not a mask. Otherwise it gets deletes with read-back first, and the caret tap at the field's right edge, where a show/hide control often sits, runs only when the read-back shows neither an empty value nor a masked placeholder. If the deletes can't reach the text, for example after the caret was moved off the end, and that text shows as many bullets as the placeholder, the read-back can't tell it from empty, so the new text is typed at the caret, next to the old text. - Use plain `fill` or `type` first. Add `--delay-ms` only when a debounced or search-as-you-type field misses characters, or the app must receive each incremental update; delayed typing enters characters one at a time instead of using a clipboard-style fallback. - `fill --text-stdin` reads the text from stdin so a secret never appears in process arguments. Pipe it with `printf %s`. It reads at most 64 KiB, removes one trailing newline, and refuses a terminal, empty input, invalid UTF-8, or an extra text argument. Output shows the value as `${VAR}` with `--record-as ` and as `[REDACTED]` otherwise, including in error messages and details, and in the `requested`, `before`, and `after` read-back of an unconfirmed fill, which can hold a reformatted form of the value. With `--settle`, the diff line text and tail labels are replaced whole, so text around the value in the field is not shown either; refs and counts stay. While script recording is armed, pass `--record-as ` or `--no-record`; passing neither is an error. Batch steps don't accept it. - The privacy controls for typed input (`--text-stdin` and `--record-as`) keep the literal out of agent-device's own responses, diagnostics, and recorded scripts. They do not rewrite what the platform records: on iOS, XCTest writes its own diagnostic logs and its `.xcresult` bundle, and typed text can appear in both, on a simulator or a physical device. Treat those as sensitive, and use test-only credentials when they may be kept or shared. See [Security and trust](/docs/security-trust).