Skip to content

fill_login: find inputs inside open shadow roots - #109

Open
drzewkoKamil wants to merge 1 commit into
DuskBotAI:mainfrom
drzewkoKamil:fix/fill-login-shadow-dom
Open

drzewkoKamil wants to merge 1 commit into
DuskBotAI:mainfrom
drzewkoKamil:fix/fill-login-shadow-dom

Conversation

@drzewkoKamil

Copy link
Copy Markdown

Fixes #108.

What and why

fill_login could not fill logins on sites whose inputs are in open shadow roots (e.g. Material Web md-outlined-text-field):
every lookup used document.querySelector(All), so the finder saw no inputs and answered "No login fields found".
This adds a shadow-aware search (deepAll, in page order) and uses it for finding, marking, focusing, clearing and
choosing the sign-in control; orders username/password by their index in that list instead of compareDocumentPosition
(meaningless across shadow trees); reads the deepest activeElement; and lets visible() walk up through shadow hosts.
CLICK_POINT in box-login-page.ts finds its target the same way and hit-tests against the element's own root.

How it was checked

  • New test in server/login-fill.test.ts with a shadow-root form: fails before, passes after (34 tests pass).

  • FakeLoginPage now looks through shadow roots for the focused element.

  • Ran the real page scripts in an isolated DevTools world on a live Material Web login page: before username: false, password: false, after true / true, and both fields take focus. Nothing was typed or submitted.

  • pnpm typecheck clean; oxlint clean on the changed files. box-login-page.e2e.test.ts is skipped here (no Chromium), not run.

  • pnpm typecheck, pnpm lint and pnpm test pass (login-fill suite; full suite not run)

  • New behaviour has a test

  • No secrets, personal data or local paths in the diff or screenshots

🤖 Generated with Claude Code

Sites built from web components (Material Web, Lit) keep their inputs in open
shadow roots, where document.querySelector(All) never looks, so fill_login
answered "No login fields found" on a visible login form.

Search open shadow roots in page order, order username/password by their index
in that list (compareDocumentPosition is meaningless across shadow trees), read
the deepest activeElement, and let visible() walk up through shadow hosts.
CLICK_POINT finds its target the same way.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

fill_login finds no fields on sites whose inputs live in open shadow roots (Material Web, Lit, ...)

1 participant