mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
webdriver_server
: Implement find element(s) from element according to spec (#37521)
Report `InvalidArgument` and `NoSuchElement` properly for [Find Element from Element](https://w3c.github.io/webdriver/#find-element-from-element) + [Find Elements from Element](https://w3c.github.io/webdriver/#find-elements-from-element) Testing: `./mach test-wpt -r .\tests\wpt\tests\webdriver\tests\classic\element_click .\tests\wpt\tests\webdriver\tests\classic\find_* --product servodriver` --------- Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This commit is contained in:
parent
96ef92b9ac
commit
e26532e19b
4 changed files with 18 additions and 39 deletions
|
@ -1167,12 +1167,16 @@ impl Handler {
|
|||
}
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webdriver/#find-element-from-element
|
||||
/// <https://w3c.github.io/webdriver/#find-element-from-element>
|
||||
fn handle_find_element_element(
|
||||
&self,
|
||||
element: &WebElement,
|
||||
parameters: &LocatorParameters,
|
||||
) -> WebDriverResult<WebDriverResponse> {
|
||||
// Step 4. If selector is undefined, return error with error code invalid argument.
|
||||
if parameters.value.is_empty() {
|
||||
return Err(WebDriverError::new(ErrorStatus::InvalidArgument, ""));
|
||||
}
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
match parameters.using {
|
||||
|
@ -1208,24 +1212,30 @@ impl Handler {
|
|||
));
|
||||
},
|
||||
}
|
||||
|
||||
// Step 9. If result is empty, return error with error code no such element.
|
||||
// Otherwise, return the first element of result.
|
||||
match wait_for_script_response(receiver)? {
|
||||
Ok(value) => {
|
||||
let value_resp = serde_json::to_value(
|
||||
value.map(|x| serde_json::to_value(WebElement(x)).unwrap()),
|
||||
)?;
|
||||
Ok(WebDriverResponse::Generic(ValueResponse(value_resp)))
|
||||
Ok(value) => match value {
|
||||
Some(value) => {
|
||||
let value_resp = serde_json::to_value(WebElement(value))?;
|
||||
Ok(WebDriverResponse::Generic(ValueResponse(value_resp)))
|
||||
},
|
||||
None => Err(WebDriverError::new(ErrorStatus::NoSuchElement, "")),
|
||||
},
|
||||
Err(error) => Err(WebDriverError::new(error, "")),
|
||||
}
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webdriver/#find-elements-from-element
|
||||
/// <https://w3c.github.io/webdriver/#find-elements-from-element>
|
||||
fn handle_find_elements_from_element(
|
||||
&self,
|
||||
element: &WebElement,
|
||||
parameters: &LocatorParameters,
|
||||
) -> WebDriverResult<WebDriverResponse> {
|
||||
// Step 4. If selector is undefined, return error with error code invalid argument.
|
||||
if parameters.value.is_empty() {
|
||||
return Err(WebDriverError::new(ErrorStatus::InvalidArgument, ""));
|
||||
}
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
match parameters.using {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
[navigate.py]
|
||||
expected: TIMEOUT
|
||||
[test_numbers_link]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -12,21 +11,12 @@
|
|||
[test_link_hash]
|
||||
expected: FAIL
|
||||
|
||||
[test_link_from_toplevel_context_with_target[\]]
|
||||
expected: FAIL
|
||||
|
||||
[test_link_from_toplevel_context_with_target[_blank\]]
|
||||
expected: FAIL
|
||||
|
||||
[test_link_from_toplevel_context_with_target[_parent\]]
|
||||
expected: FAIL
|
||||
|
||||
[test_link_from_toplevel_context_with_target[_self\]]
|
||||
expected: FAIL
|
||||
|
||||
[test_link_from_toplevel_context_with_target[_top\]]
|
||||
expected: FAIL
|
||||
|
||||
[test_link_from_nested_context_with_target[\]]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -5,15 +5,6 @@
|
|||
[test_no_such_element_with_shadow_root]
|
||||
expected: FAIL
|
||||
|
||||
[test_no_such_element_with_unknown_selector[not-existent\]]
|
||||
expected: FAIL
|
||||
|
||||
[test_no_such_element_with_unknown_selector[existent-other-frame\]]
|
||||
expected: FAIL
|
||||
|
||||
[test_no_such_element_with_unknown_selector[existent-inside-shadow-root\]]
|
||||
expected: FAIL
|
||||
|
||||
[test_no_such_element_with_startnode_from_other_frame]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -11,18 +11,6 @@
|
|||
[test_find_elements[xpath-//a\]]
|
||||
expected: FAIL
|
||||
|
||||
[test_find_elements_link_text[<a href=#>link<br>text</a>-link\\ntext\]]
|
||||
expected: FAIL
|
||||
|
||||
[test_find_elements_link_text[<a href=# style='text-transform: uppercase'>link text</a>-LINK TEXT\]]
|
||||
expected: FAIL
|
||||
|
||||
[test_find_elements_partial_link_text[<a href=#>partial link<br>text</a>-k\\nt\]]
|
||||
expected: FAIL
|
||||
|
||||
[test_find_elements_partial_link_text[<a href=# style='text-transform: uppercase'>partial link text</a>-LINK\]]
|
||||
expected: FAIL
|
||||
|
||||
[test_xhtml_namespace[xpath-//*[name()='a'\]\]]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue