Skip to content

fix: GeckodriverElement W3C serialization for connect-existing mode#58

Open
freema wants to merge 1 commit intomainfrom
fix/geckodriver-element-serialization
Open

fix: GeckodriverElement W3C serialization for connect-existing mode#58
freema wants to merge 1 commit intomainfrom
fix/geckodriver-element-serialization

Conversation

@freema
Copy link
Copy Markdown
Collaborator

@freema freema commented Mar 30, 2026

Summary

  • GeckodriverElement serialized as {} when passed through JSON.stringify(), because it only had private fields and no toJSON() method
  • Added toJSON() returning the W3C element reference format ({"element-6066-11e4-a52e-4f735466cecf": id})
  • This fixes all UID-based tools that pass elements via executeScript() or the Actions API in --connect-existing mode

Affected tools

Tool Issue Root cause
hover_by_uid Broken actions().move({ origin: el }) serialization
drag_by_uid_to_uid Broken executeScript(..., fromEl, toEl)
screenshot_by_uid Partial scrollIntoView(arguments[0])
upload_file_by_uid Partial executeScript(..., el)
evaluate_script Broken (with UID args) executeScript(..., resolvedArgs)

Tools using direct HTTP calls (click_by_uid, fill_by_uid) were not affected.

Test plan

  • 3 new unit tests verifying W3C serialization via findElement, executeScript, and actions().move()
  • 424/424 tests pass

Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=2027635

GeckodriverElement lacked a toJSON() method, causing it to serialize as
{} instead of the W3C element reference format when passed through
JSON.stringify(). This broke hover_by_uid, drag_by_uid_to_uid,
screenshot_by_uid, upload_file_by_uid and evaluate_script in
connect-existing mode.
@freema freema requested a review from juliandescottes March 30, 2026 13:33
Copy link
Copy Markdown
Collaborator

@juliandescottes juliandescottes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

I don't know the connect-existing setup well enough, but now that the issue related to BiDi was fixed, do you think we could use a regular driver instance?

In general, it would be great if connecting to an existing instance was using the same setup to avoid bugs and inconsistencies.

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.

2 participants