Implement tag name selector for FindElementFromElement WebDriver command

This commit is contained in:
George Roman 2019-06-17 17:03:09 +03:00
parent dec73e4cea
commit 616a81fb27
5 changed files with 54 additions and 16 deletions

View file

@ -259,6 +259,26 @@ pub fn handle_find_element_element_css(
reply.send(node_id).unwrap();
}
pub fn handle_find_element_element_tag_name(
documents: &Documents,
pipeline: PipelineId,
element_id: String,
selector: String,
reply: IpcSender<Result<Option<String>, ()>>,
) {
let node_id = find_node_by_unique_id(documents, pipeline, element_id)
.ok_or(())
.and_then(|node| match node.downcast::<Element>() {
Some(elem) => Ok(elem
.GetElementsByTagName(DOMString::from(selector))
.elements_iter()
.next()),
None => Err(()),
})
.map(|node| node.map(|x| x.upcast::<Node>().unique_id()));
reply.send(node_id).unwrap();
}
pub fn handle_find_element_elements_css(
documents: &Documents,
pipeline: PipelineId,