Bug 300462

Summary: [WebDriver] Elements references nested in arrays or objects are not extracted when executing scripts
Product: WebKit Reporter: Lauro Moura <lmoura>
Component: WebDriverAssignee: Lauro Moura <lmoura>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Lauro Moura
Reported 2025-10-09 13:40:46 PDT
Currently, `Session::executeScript` calls `Session::extractElement` (to unwrap the element references) only for top level arguments, not taking in account that the references can be nested in an array or object also passed as argument. Due to this, those nested references are not translated correctly by the browser, which will show them as plain objects instead of the actual DOM elements they refer to. This affects, for example, the `relative_by` Selenium selectors, as they might pass element references nested in a JS object as the parameter to their own JS snippets. With the broken references, usually the operation fails with "Message: Unsupported locator strategy: element-6066-11e4-a52e-4f735466cecf". We should traverse the incoming arrays and objects, processing the references accordingly (kinda similar to the "JSON deserialize" algorithm: https://www.w3.org/TR/webdriver/#dfn-json-deserialize). Patch incoming.
Attachments
Lauro Moura
Comment 1 2025-10-12 21:10:44 PDT
EWS
Comment 2 2025-10-13 20:02:08 PDT
Committed 301445@main (7b619594eed4): <https://commits.webkit.org/301445@main> Reviewed commits have been landed. Closing PR #52213 and removing active labels.
Radar WebKit Bug Importer
Comment 3 2025-10-13 20:03:13 PDT
Note You need to log in before you can comment on or make changes to this bug.