Skip to content

Reach web pages and sign-in sheets through AXe web refs - #173

Merged
bitomule merged 2 commits into
mainfrom
worktree-t-mav-156-out-of-process-content
Dec 3, 2026
Merged

bitomule merged 2 commits into
mainfrom
worktree-t-mav-156-out-of-process-content

Conversation

@bitomule

@bitomule bitomule commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Closes #156.

Problem

WKWebView pages, Safari, SFSafariViewController and the sign-in sheet of ASWebAuthenticationSession render in WebKit's own processes. The accessibility tree that mav ui tree reads shows at most their host view. Reproduced with a minimal app on an iPhone 17 Pro simulator, iOS 26.4, AXe 2.2.0: the sign-in sheet showed a username field, a password field and a "Log in" button, while the tree held only the app's own two buttons. As a result:

$ mav ui tap --text "Log in"
fail code=elementNotFound delivery=notSent driver=axe error="elementNotFound: No accessibility element matched --label 'Log in'. ..."

What reaches it

AXe 2.1.0 added describe-ui --agent --web. It hit-tests the screen, finds each page and lists the links, buttons and fields a tap would reach as w refs. A checked ref tap (--snapshot-id, --expected-pid) re-checks the element under the ref just before input. This works for in-app WKWebViews (with or without isInspectable), Safari, SFSafariViewController and ASWebAuthenticationSession. ui tree --point X,Y also reaches into the page, element by element.

Change

  • Fallback behind the existing selectors. After AXe reports elementNotFound with nothing sent, a --text tap on a simulator with AXe >= 2.1.0 taps the one web control whose label (or, failing that, value/placeholder) matches, through a checked ref. mav ui type TEXT --text LABEL, flow tap: {text: ...} and type: {where: {text: ...}} get it too, and the flow records selector_via=web.
  • mav ui web lists the page's controls: web ref=w3 role=button label="Log in" action=tap.
  • Clear failures. A miss on a screen with web content adds web_controls=N and a next=. A wait/assert/ui wait timeout does the same, plus web_match= when the text is a control's label. Page text is not listed, so the message points at the screenshot. With an AXe older than 2.1.0, a miss on a screen whose tree shows a web host (SFAuthenticationView, WKWebView, ...) adds web_content=unreadable and names the upgrade.
  • Safety.
    • A miss whose input may have been delivered is never followed by a web tap.
    • A selector with --id or --value is never redirected to a web control.
    • Held, repeated, delayed, styled, multi-touch and selected-input taps are explained, not sent.
    • Two controls with one label fail with selector_ambiguous, which lists them.
    • A failed ref tap keeps its delivery (retry=unsafe when partial).
    • --verify reports verified=unavailable, because the native tree cannot see the page.
  • Cost. Nothing new runs on success paths or on wait polls. The web capture (~0.3 s) runs only after a miss or a timeout.
  • Unchanged. The AXe minimum stays at 2.0.4; web support is a feature gate. The goal engine's snapshot does not ask for --web.

Docs: README "Web content and sign-in sheets" plus a Troubleshooting entry, skills/mav/SKILL.md, docs/axe2.md, and mav help ui web / ui tree / ui tap.

Validation

Real simulator (iPhone 17 Pro, iOS 26.4, AXe 2.2.0), with a throwaway app that opens an ASWebAuthenticationSession sheet and an in-app WKWebView:

$ mav ui web
ok cmd=ui.web controls=5 driver=axe ...
web ref=w1 role=text-field label=Username value=Username action=typeText
web ref=w2 role=text-field value=Password action=typeText
web ref=w3 role=button label="Log in" action=tap
...
$ mav ui tap --text "Log in"
ok cmd=ui.tap driver=axe text="Log in" via=web web_ref=w3 web_role=button ...
$ mav ui wait --text "Log in" --timeout 1s
fail code=ui_wait_timeout next="\"Log in\" is a control of web content (...), which the accessibility tree cannot see, ..." web_controls=5 web_match=w3:button
  • A flow that types into both fields and taps "Log in" passed (steps=6); the screenshot showed the page's "Submitted" state.
  • On the WKWebView consent page, ui type ... --text Email and ui tap --text "Accept all" landed.

Tests: 19 in internal/mav/web_content_test.go and 4 in internal/mav/drivers/axe/web_test.go, on fixtures shaped like AXe 2.2.0's real output. With the fallback and the explanations disabled, 9 of the behaviour tests fail. With the review fixes reverted, the uncertain-delivery, id-redirect and verify tests fail. The rest guard unchanged behaviour (no web content, old AXe without a web host). make check passes.

Not covered

  • Page text cannot be read through refs, so waits and assertions on web text still need a screenshot check. mav now says so.
  • Physical devices: AXe refs are simulator-only. Use ui tree --point and coordinates.
  • The goal engine could add --web to its snapshot so a goal can act on web controls. Left out to keep this change to the selector path.

Web views, Safari, SFSafariViewController and ASWebAuthenticationSession
render out of process, so the accessibility tree shows at most their host
view. With AXe >= 2.1.0 on a simulator, a --text tap or type that misses in
the tree now falls back to the page's controls through AXe's checked web
refs, and mav ui web lists them. Misses and wait timeouts on such screens
say why, and an older AXe names the upgrade. The goal engine snapshot is
unchanged.
Never follow a miss whose input may have been delivered, never redirect a
selector with an id or value, keep delays and tap styles out of ref taps,
report verified=unavailable for web taps, carry the receipt, explain legacy
flow waits, and probe AXe once on the failure path.
@bitomule
bitomule force-pushed the worktree-t-mav-156-out-of-process-content branch from 1dab217 to b4a8012 Compare December 3, 2026 00:11
@bitomule
bitomule merged commit d7ad6f6 into main Dec 3, 2026
1 check passed
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.

Content rendered out of process (ASWebAuthenticationSession, web views) is invisible to the tree

1 participant