Skip to content

iphone_type_text: support replace: true through WDA #161

Closed

Description

@Derrors

Follow-up to #158 / #159.

Now

#159 adds replace: true to iphone_type_text (replace the focused field's text, or empty it with empty text; Return is pressed only after the field reads back as exactly the new text). It only works with native control (iOS 27+, no WDA). Through WDA it refuses with "Replacing text requires native control" and types nothing. It does not fall back to typing at the cursor, which is the behavior we want to keep.

So phones driven through WDA (iOS 26 and earlier, or ICTL_IOS_BACKEND=wda) can't replace or empty a field. Agents fall back to typing at the cursor and get wifi 蓝牙, the problem #158 started from.

Proposal

Implement ReplaceText in the WDA path of the daemon with WDA's element endpoints:

  1. GET /session/:id/element/active → the focused element (refuse when there is none, or it isn't a TextField / SearchField / TextView; refuse SecureTextField as the native path does).
  2. POST /session/:id/element/:uuid/clear.
  3. Non-empty text: POST /session/:id/element/:uuid/value (or /wda/keys, which type_text already uses and verifies).
  4. Read the same element's value back and compare it with text exactly, with the same placeholder rule as the native path (an empty field may report its placeholder as its value). Only then press Return for submit.
  5. On failure after clear, say so plainly: unlike the native path there is no selection to undo, the old text is gone.

Notes:

  • clear doesn't work in some custom fields; fall back to select all (/wda/keys with Cmd-A isn't available on a software keyboard), or refuse with a clear message, but never report success without the read-back.
  • Tests: tests/device/scenarios.py editing already covers wifi → wi → 蓝牙 → empty, and skips on WDA. It should run there once this lands.

🤖 Generated with Claude Code

Activity

  1. added
    enhancement
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions