Implement tag name selector for FindElements WebDriver command

This commit is contained in:
George Roman 2019-06-17 16:35:34 +03:00
parent 7d5b324bda
commit dec73e4cea
5 changed files with 47 additions and 14 deletions

View file

@ -223,6 +223,25 @@ pub fn handle_find_elements_css(
reply.send(node_ids).unwrap();
}
pub fn handle_find_elements_tag_name(
documents: &Documents,
pipeline: PipelineId,
selector: String,
reply: IpcSender<Result<Vec<String>, ()>>,
) {
let node_ids = documents
.find_document(pipeline)
.ok_or(())
.and_then(|doc| Ok(doc.GetElementsByTagName(DOMString::from(selector))))
.map(|nodes| {
nodes
.elements_iter()
.map(|x| x.upcast::<Node>().unique_id())
.collect::<Vec<String>>()
});
reply.send(node_ids).unwrap();
}
pub fn handle_find_element_element_css(
documents: &Documents,
pipeline: PipelineId,