Closed Bug 2027635 Opened 17 days ago Closed 13 days ago

[firefox-devtools-mcp] UID-based tools partially broken in connect-existing mode (element serialization)

Categories

(Developer Infrastructure :: AI for Development, defect, P3)

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jdescottes, Unassigned)

References

(Blocks 1 open bug, )

Details

Bug

GeckodriverHttpDriver returns GeckodriverElement wrappers from findElement(), but these don't serialize to W3C element references ({"element-6066-...": "id"}). When passed as arguments to executeScript or actions().move(), geckodriver doesn't recognize them.

Impact by tool

Tool Status Reason
click_by_uid Works Uses GeckodriverElement.click() (direct HTTP)
fill_by_uid Works Uses el.clear() + el.sendKeys() (direct HTTP)
hover_by_uid Broken actions().move({ origin: el }) — el serializes wrong
drag_by_uid_to_uid Broken executeScript('...', fromEl, toEl) — elements become null in browser
upload_file_by_uid Partial executeScript part broken, sendKeys works
screenshot_by_uid Partial scrollIntoView broken, takeScreenshot() works via HTTP
evaluate_script with UID args Broken Elements passed as raw args

Root cause

GeckodriverHttpDriver.executeScript() sends args raw via JSON:

async executeScript<T>(script: string, ...args: unknown[]): Promise<T> {
  return (await this.cmd('POST', '/execute/sync', { script, args })) as T;
}

GeckodriverElement is a plain JS object — it serializes to {}, not a W3C element reference.

Possible fix

GeckodriverElement needs a toJSON() method (or similar) that returns the W3C element reference format, and executeScript/actions need to convert elements before sending. Alternatively, implement ELEMENT_KEY serialization like selenium-webdriver does.

README currently states for connect-existing: "all other features work normally" — this is inaccurate for the tools listed above.

Refs: src/firefox/core.ts:303, src/firefox/core.ts:320, src/firefox/core.ts:419, src/firefox/dom.ts:184, src/firefox/dom.ts:221, src/firefox/dom.ts:274, src/firefox/dom.ts:336

Status: NEW → RESOLVED
Closed: 13 days ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.