[WebDriver] Implement XPath Locator Strategy (#37783)

1. Implement XPath Locator Strategy
2. Use it for "Find Element(s)", "Find Element(s) from Element", "Find
Element(s) from Shadow Root"

Testing: `tests\wpt\tests\webdriver\tests\classic\find_element*\find.py`

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This commit is contained in:
Euclid Ye 2025-07-01 01:20:52 +08:00 committed by GitHub
parent f682f9d6f5
commit d781d1b1cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 190 additions and 51 deletions

View file

@ -2270,6 +2270,15 @@ impl ScriptThread {
can_gc,
)
},
WebDriverScriptCommand::FindElementsXpathSelector(selector, reply) => {
webdriver_handlers::handle_find_elements_xpath_selector(
&documents,
pipeline_id,
selector,
reply,
can_gc,
)
},
WebDriverScriptCommand::FindElementElementsCSSSelector(selector, element_id, reply) => {
webdriver_handlers::handle_find_element_elements_css_selector(
&documents,
@ -2303,6 +2312,18 @@ impl ScriptThread {
can_gc,
)
},
WebDriverScriptCommand::FindElementElementsXPathSelector(
selector,
element_id,
reply,
) => webdriver_handlers::handle_find_element_elements_xpath_selector(
&documents,
pipeline_id,
element_id,
selector,
reply,
can_gc,
),
WebDriverScriptCommand::FindShadowElementsCSSSelector(
selector,
shadow_root_id,
@ -2337,6 +2358,18 @@ impl ScriptThread {
reply,
)
},
WebDriverScriptCommand::FindShadowElementsXPathSelector(
selector,
shadow_root_id,
reply,
) => webdriver_handlers::handle_find_shadow_elements_xpath_selector(
&documents,
pipeline_id,
shadow_root_id,
selector,
reply,
can_gc,
),
WebDriverScriptCommand::GetElementShadowRoot(element_id, reply) => {
webdriver_handlers::handle_get_element_shadow_root(
&documents,