mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Add webdriver command Find elements from element
This commit is contained in:
parent
0b19a3dbfb
commit
816e599db3
4 changed files with 67 additions and 1 deletions
|
@ -1872,6 +1872,15 @@ impl ScriptThread {
|
|||
reply,
|
||||
)
|
||||
},
|
||||
WebDriverScriptCommand::FindElementElementsCSS(selector,element_id,reply) => {
|
||||
webdriver_handlers::handle_find_element_elements_css(
|
||||
&*documents,
|
||||
pipeline_id,
|
||||
element_id,
|
||||
selector,
|
||||
reply,
|
||||
)
|
||||
},
|
||||
WebDriverScriptCommand::FocusElement(element_id, reply) => {
|
||||
webdriver_handlers::handle_focus_element(
|
||||
&*documents,
|
||||
|
|
|
@ -220,6 +220,27 @@ pub fn handle_find_element_element_css(
|
|||
reply.send(node_id).unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_find_element_elements_css(
|
||||
documents: &Documents,
|
||||
pipeline: PipelineId,
|
||||
element_id: String,
|
||||
selector: String,
|
||||
reply: IpcSender<Result<Option<String>, ()>>,
|
||||
){
|
||||
let node_ids = find_node_by_unique_id(documents,pipeline,element_id)
|
||||
.ok_or(())
|
||||
.and_then(|node|{
|
||||
node.query_selector_all(DOMString::from(selector)).map_err(|_| ())
|
||||
})
|
||||
.map(|nodes| {
|
||||
nodes
|
||||
.iter()
|
||||
.map(|x| Some(x.upcast::<Node>().unique_id()))
|
||||
.collect()
|
||||
});
|
||||
reply.send(node_ids).unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_focus_element(
|
||||
documents: &Documents,
|
||||
pipeline: PipelineId,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue