Confirmed users
1,905
edits
No edit summary |
|||
| Line 8: | Line 8: | ||
=== Context Management === | === Context Management === | ||
* {{done|'''set_context(context)'''}}: sets the context in which future commands will be executed; | * {{done|'''set_context(context)'''}}: sets the context in which future commands will be executed; <code>context</code> is either "chrome" or "content" | ||
* {{ok|'''get_window()'''}}: returns an id representing the current window | * {{ok|'''get_window()'''}}: returns an id representing the current window | ||
* {{ok|'''get_windows()'''}}: returns a list of all available windows | * {{ok|'''get_windows()'''}}: returns a list of all available windows | ||
* {{ok|'''switch_to_window(window)'''}}: sets the active window; all future commands will be targeted here. | * {{ok|'''switch_to_window(window)'''}}: sets the active window; all future commands will be targeted here. <code>window</code> is one of the id's returned by <code>get_windows()</code>. | ||
* {{ok|'''switch_to_frame(id)'''}}: sets the active frame; all future commands will be targeted here. | * {{ok|'''switch_to_frame(id)'''}}: sets the active frame; all future commands will be targeted here. <code>id</code> is either the id of an iframe, an HTMLElement (see below) representing an iframe, or None to target the default top-level frame. | ||
=== Navigation === | === Navigation === | ||
| Line 25: | Line 25: | ||
* {{done|'''execute_script(script)'''}}: executes a synchronous JavaScript script, and returns the value which the script returns | * {{done|'''execute_script(script)'''}}: executes a synchronous JavaScript script, and returns the value which the script returns | ||
* {{done|'''execute_async_script(script)'''}}: executes an asynchronous JavaScript script; returns only when script calls <code>marionetteScriptFinished(return_value);</code>. script will generate a TimeoutException if the script does not call <code>marionetteScriptFinished</code> within the timeout specified by | * {{done|'''execute_async_script(script)'''}}: executes an asynchronous JavaScript script; returns only when script calls <code>marionetteScriptFinished(return_value);</code>. script will generate a <code>TimeoutException</code> if the script does not call <code>marionetteScriptFinished</code> within the timeout specified by <code>set_script_timeout</code>. | ||
For both methods, scripts can not set global variables which persist between script executions. Instead, scripts wishing to share data between calls should add properties to the window object. For scripts executed in the content context, security restrictions require that custom properties of the window object be accessed using window.wrappedJSObject. | For both methods, scripts can not set global variables which persist between script executions. Instead, scripts wishing to share data between calls should add properties to the window object. For scripts executed in the content context, security restrictions require that custom properties of the window object be accessed using <code>window.wrappedJSObject</code>. | ||
=== HTML Interaction === | |||
* {{done|'''find_element(method, target)'''}}: returns an HTMLElement object representing an HTML Element, which can be used with other HTML interaction methods. <code>method</code> is one of: <code>HTMLElement.CLASS</code>, <code>HTMLElement.ID</code>, <code>HTMLElement.NAME</code>, or <code>HTMLElement.TAG</code>. Methods planned but not yet implemented are: <code>HTMLElement.SELECTOR</code>, <code>HTMLElement.XPATH</code>, <code>HTMLElement.LINK_TEXT</code>, and <code>HTMLElement.PARTIAL_LINK_TEXT</code>. If multiple elements match the specified method and target, only the first (in DOM order) is returned. | |||
* {{ok|'''find_elements(method, target)'''}}: same as above, but returns a list of all elements that match the specified method and target. | |||
NYI: variations of the above two methods which accept a third parameter, which is an HTMLElement under which the find should be performed. | |||
==== HTMLElement Methods ==== | |||
All of the following are methods of HTMLElement objects, returned by the find_ methods above. | |||
* {{done|'''click()'''}}: clicks the element | |||
* {{ok|'''get_attribute(attr)'''}}: returns the value of the specified attribute | |||
* {{ok|'''text()'''}}: returns the element's text, if any | |||
* {{ok|'''send_keys(string)'''}}: sends key events to the element. The format of 'string' is defined at http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value | |||
* {{ok|'''value()'''}}: returns the element's value | |||
* {{ok|'''clear()'''}}: clears the element's input, e.g., for text fields | |||
* {{ok|'''selected()'''}}: returns True if the element is currently selected | |||
* {{ok|'''enabled()'''}}: returns True if the element is currently enabled | |||
* {{ok|'''displayed()'''}}: returns True if the element is currently displayed | |||