mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Implement tag name selector for FindElement WebDriver command
This commit is contained in:
parent
4128a38936
commit
7d5b324bda
5 changed files with 45 additions and 15 deletions
|
@ -2019,6 +2019,14 @@ impl ScriptThread {
|
|||
reply,
|
||||
)
|
||||
},
|
||||
WebDriverScriptCommand::FindElementTagName(selector, reply) => {
|
||||
webdriver_handlers::handle_find_element_tag_name(
|
||||
&*documents,
|
||||
pipeline_id,
|
||||
selector,
|
||||
reply,
|
||||
)
|
||||
},
|
||||
WebDriverScriptCommand::FindElementsCSS(selector, reply) => {
|
||||
webdriver_handlers::handle_find_elements_css(
|
||||
&*documents,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -25,6 +25,7 @@ pub enum WebDriverScriptCommand {
|
|||
ExecuteScript(String, IpcSender<WebDriverJSResult>),
|
||||
ExecuteAsyncScript(String, IpcSender<WebDriverJSResult>),
|
||||
FindElementCSS(String, IpcSender<Result<Option<String>, ()>>),
|
||||
FindElementTagName(String, IpcSender<Result<Option<String>, ()>>),
|
||||
FindElementsCSS(String, IpcSender<Result<Vec<String>, ()>>),
|
||||
FindElementElementCSS(String, String, IpcSender<Result<Option<String>, ()>>),
|
||||
FindElementElementsCSS(String, String, IpcSender<Result<Option<String>, ()>>),
|
||||
|
|
|
@ -804,18 +804,26 @@ impl Handler {
|
|||
&self,
|
||||
parameters: &LocatorParameters,
|
||||
) -> WebDriverResult<WebDriverResponse> {
|
||||
if parameters.using != LocatorStrategy::CSSSelector {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
match parameters.using {
|
||||
LocatorStrategy::CSSSelector => {
|
||||
let cmd = WebDriverScriptCommand::FindElementCSS(parameters.value.clone(), sender);
|
||||
self.browsing_context_script_command(cmd)?;
|
||||
},
|
||||
LocatorStrategy::TagName => {
|
||||
let cmd =
|
||||
WebDriverScriptCommand::FindElementTagName(parameters.value.clone(), sender);
|
||||
self.browsing_context_script_command(cmd)?;
|
||||
},
|
||||
_ => {
|
||||
return Err(WebDriverError::new(
|
||||
ErrorStatus::UnsupportedOperation,
|
||||
"Unsupported locator strategy",
|
||||
));
|
||||
},
|
||||
}
|
||||
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
let cmd = WebDriverScriptCommand::FindElementCSS(parameters.value.clone(), sender);
|
||||
self.browsing_context_script_command(cmd)?;
|
||||
|
||||
match receiver.recv().unwrap() {
|
||||
Ok(value) => {
|
||||
let value_resp = serde_json::to_value(
|
||||
|
|
|
@ -11,9 +11,6 @@
|
|||
[test_find_element_partial_link_text[<a href=#> partial link text </a>-link\]]
|
||||
expected: FAIL
|
||||
|
||||
[test_htmldocument[tag name-html\]]
|
||||
expected: FAIL
|
||||
|
||||
[test_find_element_link_text[<a href=#>link<br>text</a>-link\ntext\]]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -62,9 +59,6 @@
|
|||
[test_find_element_partial_link_text[<a href=#>partial link text</a>-k t\]]
|
||||
expected: FAIL
|
||||
|
||||
[test_find_element[tag name-a\]]
|
||||
expected: FAIL
|
||||
|
||||
[test_xhtml_namespace[partial link text-link text\]]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue