From 09b9293b092a89aaca651f3ce655e5a97878e52c Mon Sep 17 00:00:00 2001 From: James Graham Date: Tue, 16 Jun 2015 17:32:42 +0100 Subject: Implement support for WebDriver send keys command. Supports sending keys to an element. The specification here is still rather unfinished so the error handling and so on in this code will need iteration as it becomes clearer what the expected behaviour is. --- components/script/webdriver_handlers.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'components/script/webdriver_handlers.rs') diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs index 8a2385ae0f4..cd49c8126f7 100644 --- a/components/script/webdriver_handlers.rs +++ b/components/script/webdriver_handlers.rs @@ -4,6 +4,7 @@ use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; +use dom::bindings::codegen::Bindings::HTMLElementBinding::HTMLElementMethods; use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods; @@ -11,6 +12,7 @@ use dom::bindings::conversions::{FromJSValConvertible, StringificationBehavior}; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::element::Element; +use dom::htmlelement::HTMLElement; use dom::htmliframeelement::HTMLIFrameElement; use dom::node::Node; use dom::window::ScriptHelpers; @@ -147,6 +149,25 @@ pub fn handle_find_elements_css(page: &Rc, }).unwrap(); } +pub fn handle_focus_element(page: &Rc, + pipeline: PipelineId, + element_id: String, + reply: IpcSender>) { + reply.send(match find_node_by_unique_id(page, pipeline, element_id) { + Some(ref node) => { + match node.downcast::() { + Some(ref elem) => { + // Need a way to find if this actually succeeded + elem.Focus(); + Ok(()) + } + None => Err(()) + } + }, + None => Err(()) + }).unwrap(); +} + pub fn handle_get_active_element(page: &Rc, _pipeline: PipelineId, reply: IpcSender>) { -- cgit v1.2.3