Skip to content

WebDriver BiDi: support for locating DOM nodes via browsingContext.locateNodes #46980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AnujPanta1
Copy link
Contributor

@AnujPanta1 AnujPanta1 commented Jun 20, 2025

373034c

WebDriver BiDi: support for locating DOM nodes via `browsingContext.locateNodes`
rdar://137019465

Reviewed by NOBODY (OOPS!).

Adding the majority of work for the locateNodes endpoint. The main focus is a need for a new JS
script as the classic implementation found as an atom couldn't be modified for the BIDI
specification. A current bug with the dispatcher https://bugs.webkit.org/show_bug.cgi?id=294633
has blocked end-to-end testing. The new script was individually tested against a test site,
ensuring each type of locator worked. Currently, the callback from evaluateJavaScriptFunction
is bare as it's difficult to create a thorough solution without testing.

* Source/WebKit/UIProcess/Automation/BidiBrowsingContextAgent.cpp:
(WebKit::BidiBrowsingContextAgent::locateNodes):
* Source/WebKit/UIProcess/Automation/BidiBrowsingContextAgent.h:
* Source/WebKit/UIProcess/Automation/protocol/BidiBrowsingContext.json:
* Source/WebKit/UIProcess/Automation/protocol/BidiScript.json:

373034c

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
❌ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ⏳ 🧪 win-tests
✅ 🧪 webkitperl ❌ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🛠 wpe-cairo
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ❌ 🧪 api-gtk
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

…ocateNodes`

rdar://137019465

Reviewed by NOBODY (OOPS!).

Adding the majority of work for the locateNodes endpoint. The main focus is a need for a new JS
script as the classic implementation found as an atom couldn't be modified for the BIDI
specification. A current bug with the dispatcher https://bugs.webkit.org/show_bug.cgi?id=294633
has blocked end-to-end testing. The new script was individually tested against a test site,
ensuring each type of locator worked. Currently, the callback from evaluateJavaScriptFunction
is bare as it's difficult to create a thorough solution without testing.

* Source/WebKit/UIProcess/Automation/BidiBrowsingContextAgent.cpp:
(WebKit::BidiBrowsingContextAgent::locateNodes):
* Source/WebKit/UIProcess/Automation/BidiBrowsingContextAgent.h:
* Source/WebKit/UIProcess/Automation/protocol/BidiBrowsingContext.json:
* Source/WebKit/UIProcess/Automation/protocol/BidiScript.json:
@AnujPanta1 AnujPanta1 requested a review from cdumez as a code owner June 20, 2025 08:49
@AnujPanta1 AnujPanta1 self-assigned this Jun 20, 2025
auto page = session->webPageProxyForHandle(context);
ASYNC_FAIL_WITH_PREDEFINED_ERROR_IF(!page, WindowNotFound);

String locateNodeFunction = R"(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Couldn't quite figure out how to move into its own atom file, ended up growing into quite a large string 😞

@AnujPanta1 AnujPanta1 requested a review from burg June 20, 2025 08:53
@AnujPanta1 AnujPanta1 added the WebDriver Bugs in WebDriver label Jun 20, 2025
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 20, 2025

session->evaluateJavaScriptFunction(context, emptyString(), locateNodeFunction, *arguments, true, false, callbackTimeout.value(),
[callback = WTFMove(callback)](Inspector::CommandResult<String>&& result) mutable {

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think the newlines here are unnecessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merging-blocked Applied to prevent a change from being merged WebDriver Bugs in WebDriver
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants