Repository navigation
Browser backend: an element's number points at the element it was read from - #67
Open
haydenunstacked wants to merge 1 commit into
Open
haydenunstacked wants to merge 1 commit into
haydenunstacked wants to merge 1 commit into
Conversation
… the element it was read from The page script numbered elements in document order, sorted them into reading order, then renumbered by finding each element by its old number. Old and new numbers shared the attribute while that loop ran, so an element already renumbered, and earlier in the document, could be found instead and renumbered a second time. The handles stayed unique, so nothing failed: a click or typed text went to a live element other than the one reported. On en.wikipedia.org/wiki/Whataburger 18 to 20 of about 60 handles sat on a different element. With three inputs drawn out of document order, text chosen for a plain field went into the password input. The script now keeps each element and stamps it once, after the sort. What it returns is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On pages where reading order and document order differ in a particular way,
data-tscuhandles end up on the wrong elements, so a click or typed text goes to a different element from the one the classifier chose. Nothing fails, and the step log shows the right name.Cause. The page script in
browser/perceive.pystamped each element in document order, sorted into reading order, then renumbered by finding each element by its old number:Old and new numbers share the attribute while that loop runs. When an element already renumbered holds the number being looked up, and sits earlier in the document, it is found instead and renumbered a second time.
When. Something late in the document sorts ahead of two or more earlier elements: a sidebar beside the main column, a fixed header or a dialog at the end of the document. Swapping two neighbours or reversing a whole list is harmless. Exactly: with
s[i]the document rank of the element at sorted positioni, someihass[s[i]] < s[i] < i.Smallest page. Three links in document order Alpha, Bravo, Charlie, drawn Charlie, Alpha, Bravo:
perceive()reports index 1 as Alpha and index 2 as Bravo.[data-tscu="1"]is Bravo and[data-tscu="2"]is Alpha.Typing.
type_text,field_valueandclear_fielduse the same handle. With three inputs arranged the same way (Search, Password, Email in the document, drawn Email, Search, Password),typing_target(page, 1)returns Search with no refusal, andact.type_textputs the text in the password input.Measured on main at 44ca11f with the repo's headless Chrome, top of page, handles that sit on a different element from the one reported. Counts move with what the page serves on a given load.
The last row is why the fixture loop never showed it: the sort moves nothing there.
Change. The script keeps each element and stamps it once, after the sort. Nothing is found by its number any more.
This does not change what the model sees. The old and new scripts return identical output on the fixture, Hacker News, the Whataburger article and this repo's page.
The suite runs no browser, so the new test reads the script text, as its neighbours do.
ruff check,ruff format --checkandpytestpass (730 passed, 3 skipped, 1 xfailed).Generated with Claude Code