Skip to content

fix(wda): clear fields with typed backspaces on a simulator - #270

Merged
omnarayan merged 1 commit into
devicelab-dev:mainfrom
luka-vladika-happening-xyz:fix/wda-typed-clear-on-simulator
Nov 9, 2026
Merged

omnarayan merged 1 commit into
devicelab-dev:mainfrom
luka-vladika-happening-xyz:fix/wda-typed-clear-on-simulator

Conversation

@luka-vladika-happening-xyz

@luka-vladika-happening-xyz luka-vladika-happening-xyz commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

WebDriverAgent's first try at clearing a field (/element/{id}/clear, which eraseText uses) is a hardware keyboard's Clear key, an IOHIDEvent (useClearTextShortcut, on by default; its comment cites appium/appium#19389). On a simulator iOS then takes a hardware keyboard as attached, and from then on keeps the software keyboard parked below the screen whenever a field has focus (its frame at y = 891 on an 874-point screen). Whatever an app shows with the keyboard never appears: in our suite the betslip's stake chips, so tapOn: "^10$" after an eraseText found nothing for the rest of the run. Neither DeviceLab's driver nor Maestro sends such an event; Maestro erases by typing delete characters.

The change: CreateSession sends useClearTextShortcut: false when the driver's device is a simulator (NewDriver sets it from PlatformInfo.IsSimulator), so WebDriverAgent types backspaces, and true on a real device. It sends it either way, since WebDriverAgent keeps settings for the whole process.

Why not on a real iPhone too: a phone keeps its software keyboard up after the Clear key, and typed backspaces erase only what is left of the cursor. Our stake field is as wide as its text (9 pt for "3"); a tap in its middle can put the cursor before the digit, and then nothing is erased (WebDriverAgent's last try, a triple tap, only opens the edit menu there, and the clear reports success). With backspaces on five real iPhones, our two flows that change a stake missed an erase in 6 of 8 runs on the two iOS 27 phones and in none of 12 on the iOS 18 and 26 phones; with the Clear key, in none of 30, and none of 192 erases to empty missed in a probe that erases the stake six times a run (96 with this change, 96 without).

Tests: TestCreateSession checks both: a client of a real device sends true, one whose driver is a simulator's sends false (fails without the change). go test -race ./pkg/driver/wda/ ./pkg/executor/ ./pkg/flow/ passes; golangci-lint v2.13.2: 0 issues.

On devices: a simulator (iOS 27.2), our betslip_stake_validation flow: 0 of 3 before, 3 of 3 after, and the keyboard and its chips stay on screen after every eraseText. Real iPhones (iOS 18.3 to 27.2) keep the Clear key and pass as before.

WebDriverAgent's first try at clearing a field is a hardware keyboard's
Clear key (an IOHIDEvent). On a simulator iOS then takes a hardware
keyboard as attached and keeps the software keyboard parked below the
screen whenever a field has focus, so what an app shows with the keyboard
(a betslip's stake chips) never appears. A simulator's session now sets
useClearTextShortcut false: typed backspaces, as Maestro erases.

A real iPhone keeps its keyboard up after the Clear key, and typed
backspaces erase only what is left of the cursor: a tap in the middle of a
one-digit field put the cursor before the digit about half the time, and
nothing was erased. A real device's session sets it true. It is sent
either way, since WebDriverAgent keeps settings process-wide.
@codecov

codecov Bot commented Nov 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@omnarayan
omnarayan merged commit 050c15d into devicelab-dev:main Nov 9, 2026
5 checks passed
omnarayan added a commit that referenced this pull request Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants