Implement tag name selector for FindElement WebDriver command

This commit is contained in:
George Roman 2019-06-17 16:10:38 +03:00
parent 4128a38936
commit 7d5b324bda
5 changed files with 45 additions and 15 deletions

View file

@ -182,6 +182,25 @@ pub fn handle_find_element_css(
reply.send(node_id).unwrap();
}
pub fn handle_find_element_tag_name(
documents: &Documents,
pipeline: PipelineId,
selector: String,
reply: IpcSender<Result<Option<String>, ()>>,
) {
let node_id = documents
.find_document(pipeline)
.ok_or(())
.and_then(|doc| {
Ok(doc
.GetElementsByTagName(DOMString::from(selector))
.elements_iter()
.next())
})
.map(|node| node.map(|x| x.upcast::<Node>().unique_id()));
reply.send(node_id).unwrap();
}
pub fn handle_find_elements_css(
documents: &Documents,
pipeline: PipelineId,