<p>The name may optionally be followed by one or more <em>element-filters</em>, separated from the name by whitespace. If the <em>filterType</em> is not specified, <strong>value</strong> is assumed.</p>
Select the element using css selectors. Please refer to <ahref="http://www.w3.org/TR/REC-CSS2/selector.html">CSS2 selectors</a>, <ahref="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/">CSS3 selectors</a> for more information. You can also check the TestCssLocators test in the selenium test suite for an example of usage, which is included in the downloaded selenium core package.
<ulclass="first last simple">
<li>css=a[href="#id3"]</li>
<li>css=span#firstChild + span</li>
</ul>
<p>Currently the css selector locator supports all css1, css2 and css3 selectors except namespace in css3, some pseudo classes(:nth-of-type, :nth-last-of-type, :first-of-type, :last-of-type, :only-of-type, :visited, :hover, :active, :focus, :indeterminate) and pseudo elements(::first-line, ::first-letter, ::selection, ::before, ::after). </p>
Locate an element by resolving the UI specifier string to another locator, and evaluating it. See the <ahref="http://svn.openqa.org/fisheye/browse/~raw,r=trunk/selenium/trunk/src/main/resources/core/scripts/ui-doc.html">Selenium UI-Element Reference</a> for more details.
<paramname="keySequence">Either be a string("\" followed by the numeric keycode of the key to be pressed, normally the ASCII value of that key), or a single character. For example: "w", "\119".</param>
<comment>Simulates a user pressing and releasing a key.</comment>
</function>
<functionname="shiftKeyDown">
<comment>Press the shift key and hold it down until doShiftUp() is called or a new page is loaded.</comment>
</function>
<functionname="shiftKeyUp">
<comment>Release the shift key.</comment>
</function>
<functionname="metaKeyDown">
<comment>Press the meta key and hold it down until doMetaUp() is called or a new page is loaded.</comment>
</function>
<functionname="metaKeyUp">
<comment>Release the meta key.</comment>
</function>
<functionname="altKeyDown">
<comment>Press the alt key and hold it down until doAltUp() is called or a new page is loaded.</comment>
</function>
<functionname="altKeyUp">
<comment>Release the alt key.</comment>
</function>
<functionname="controlKeyDown">
<comment>Press the control key and hold it down until doControlUp() is called or a new page is loaded.</comment>
<paramname="keySequence">Either be a string("\" followed by the numeric keycode of the key to be pressed, normally the ASCII value of that key), or a single character. For example: "w", "\119".</param>
<comment>Simulates a user pressing a key (without releasing it yet).</comment>
<paramname="keySequence">Either be a string("\" followed by the numeric keycode of the key to be pressed, normally the ASCII value of that key), or a single character. For example: "w", "\119".</param>
<comment>Simulates a user releasing a key.</comment>
<comment>Simulates keystroke events on the specified element, as though you typed the value key-by-key.
<p>This is a convenience method for calling keyDown, keyUp, keyPress for every character in the specified string;
this is useful for dynamic UI widgets (like auto-completing combo boxes) that require explicit key events.</p>
<p>Unlike the simple "type" command, which forces the specified value into the page directly, this command
may or may not have any visible effect, even in cases where typing keys would normally have a visible effect.
For example, if you use "typeKeys" on a form element, you may or may not see the results of what you typed in
the field.</p>
<p>In some cases, you may need to use the simple "type" command to set the value of the field and then the "typeKeys" command to
send the keystroke events corresponding to what you just typed.</p></comment>
</function>
<functionname="setSpeed">
<paramname="value">the number of milliseconds to pause after operation</param>
<comment>Set execution speed (i.e., set the millisecond length of a delay which will follow each selenium operation). By default, there is no such delay, i.e.,
<comment>Get execution speed (i.e., get the millisecond length of the delay following each selenium operation). By default, there is no such delay, i.e.,
<comment>Uncheck a toggle-button (checkbox/radio)</comment>
</function>
<functionname="select">
<paramname="selectLocator">an <ahref="#locators">element locator</a> identifying a drop-down menu</param>
<paramname="optionLocator">an option locator (a label by default)</param>
<comment>Select an option from a drop-down using an option locator.
<p>
Option locators provide different ways of specifying options of an HTML
Select element (e.g. for selecting a specific option, or for asserting
that the selected option satisfies a specification). There are several
forms of Select Option Locator.
</p>
<ul>
<li><strong>label</strong>=<em>labelPattern</em>:
matches options based on their labels, i.e. the visible text. (This
is the default.)
<ulclass="first last simple">
<li>label=regexp:^[Oo]ther</li>
</ul>
</li>
<li><strong>value</strong>=<em>valuePattern</em>:
matches options based on their values.
<ulclass="first last simple">
<li>value=other</li>
</ul>
</li>
<li><strong>id</strong>=<em>id</em>:
matches options based on their ids.
<ulclass="first last simple">
<li>id=option1</li>
</ul>
</li>
<li><strong>index</strong>=<em>index</em>:
matches an option based on its index (offset from zero).
<ulclass="first last simple">
<li>index=2</li>
</ul>
</li>
</ul>
<p>
If no option locator prefix is provided, the default behaviour is to match on <strong>label</strong>.
</p></comment>
</function>
<functionname="addSelection">
<paramname="locator">an <ahref="#locators">element locator</a> identifying a multi-select box</param>
<paramname="optionLocator">an option locator (a label by default)</param>
<comment>Add a selection to the set of selected options in a multi-select element using an option locator.
@see #doSelect for details of option locators</comment>
</function>
<functionname="removeSelection">
<paramname="locator">an <ahref="#locators">element locator</a> identifying a multi-select box</param>
<paramname="optionLocator">an option locator (a label by default)</param>
<comment>Remove a selection from the set of selected options in a multi-select element using an option locator.
@see #doSelect for details of option locators</comment>
</function>
<functionname="removeAllSelections">
<paramname="locator">an <ahref="#locators">element locator</a> identifying a multi-select box</param>
<comment>Unselects all of the selected options in a multi-select element.</comment>
</function>
<functionname="submit">
<paramname="formLocator">an <ahref="#locators">element locator</a> for the form you want to submit</param>
<comment>Submit the specified form. This is particularly useful for forms without
submit buttons, e.g. single-input "Search" forms.</comment>
</function>
<functionname="open">
<paramname="url">the URL to open; may be relative or absolute</param>
<comment>Opens an URL in the test frame. This accepts both relative and absolute
URLs.
The "open" command waits for the page to load before proceeding,
ie. the "AndWait" suffix is implicit.
<em>Note</em>: The URL must be on the same domain as the runner HTML
due to security restrictions in the browser (Same Origin Policy). If you
need to open an URL on another domain, use the Selenium Server to start a
new browser session on that domain.</comment>
</function>
<functionname="openWindow">
<paramname="url">the URL to open, which can be blank</param>
<paramname="windowID">the JavaScript window ID of the window to select</param>
<comment>Opens a popup window (if a window with that ID isn't already open).
After opening the window, you'll need to select it using the selectWindow
command.
<p>This command can also be a useful workaround for bug SEL-339. In some cases, Selenium will be unable to intercept a call to window.open (if the call occurs during or before the "onLoad" event, for example).
In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using
an empty (blank) url, like this: openWindow("", "myFunnyWindow").</p></comment>
</function>
<functionname="selectWindow">
<paramname="windowID">the JavaScript window ID of the window to select</param>
<comment>Determines whether the specified input element is editable, ie hasn't been disabled.
This method will fail if the specified element isn't an input element.</comment>
</function>
<functionname="getAllButtons">
<returntype="string[]">the IDs of all buttons on the page</return>
<comment>Returns the IDs of all buttons on the page.
<p>If a given button has no ID, it will appear as "" in this array.</p></comment>
</function>
<functionname="getAllLinks">
<returntype="string[]">the IDs of all links on the page</return>
<comment>Returns the IDs of all links on the page.
<p>If a given link has no ID, it will appear as "" in this array.</p></comment>
</function>
<functionname="getAllFields">
<returntype="string[]">the IDs of all field on the page</return>
<comment>Returns the IDs of all input fields on the page.
<p>If a given field has no ID, it will appear as "" in this array.</p></comment>
</function>
<functionname="getAttributeFromAllWindows">
<returntype="string[]">the set of values of this attribute from all known windows.</return>
<paramname="attributeName">name of an attribute on the windows</param>
<comment>Returns every instance of some attribute from all known windows.</comment>
</function>
<functionname="dragdrop">
<paramname="locator">an element locator</param>
<paramname="movementsString">offset in pixels from the current location to which the element should be moved, e.g., "+70,-300"</param>
<comment>deprecated - use dragAndDrop instead</comment>
</function>
<functionname="setMouseSpeed">
<paramname="pixels">the number of pixels between "mousemove" events</param>
<comment>Configure the number of pixels between "mousemove" events during dragAndDrop commands (default=10).
<p>Setting this value to 0 means that we'll send a "mousemove" event to every single pixel
in between the start location and the end location; that can be very slow, and may
cause some browsers to force the JavaScript to timeout.</p>
<p>If the mouse speed is greater than the distance between the two dragged objects, we'll
just send one "mousemove" at the start location and then one final one at the end location.</p></comment>
</function>
<functionname="getMouseSpeed">
<returntype="number">the number of pixels between "mousemove" events during dragAndDrop commands (default=10)</return>
<comment>Returns the number of pixels between "mousemove" events during dragAndDrop commands (default=10).</comment>
</function>
<functionname="dragAndDrop">
<paramname="locator">an element locator</param>
<paramname="movementsString">offset in pixels from the current location to which the element should be moved, e.g., "+70,-300"</param>
<comment>Drags an element a certain distance and then drops it</comment>
</function>
<functionname="dragAndDropToObject">
<paramname="locatorOfObjectToBeDragged">an element to be dragged</param>
<paramname="locatorOfDragDestinationObject">an element whose location (i.e., whose center-most pixel) will be the point where locatorOfObjectToBeDragged is dropped</param>
<comment>Drags an element and drops it on another element</comment>
<returntype="string[]">the IDs of all windows that the browser knows about.</return>
<comment>Returns the IDs of all windows that the browser knows about.</comment>
</function>
<functionname="getAllWindowNames">
<returntype="string[]">the names of all windows that the browser knows about.</return>
<comment>Returns the names of all windows that the browser knows about.</comment>
</function>
<functionname="getAllWindowTitles">
<returntype="string[]">the titles of all windows that the browser knows about.</return>
<comment>Returns the titles of all windows that the browser knows about.</comment>
</function>
<functionname="getHtmlSource">
<returntype="string">the entire HTML source</return>
<comment>Returns the entire HTML source between the opening and
closing "html" tags.</comment>
</function>
<functionname="setCursorPosition">
<paramname="locator">an <ahref="#locators">element locator</a> pointing to an input element or textarea</param>
<paramname="position">the numerical position of the cursor in the field; position should be 0 to move the position to the beginning of the field. You can also set the cursor to -1 to move it to the end of the field.</param>
<comment>Moves the text cursor to the specified position in the given input element or textarea.
This method will fail if the specified element isn't an input element or textarea.</comment>
</function>
<functionname="getElementIndex">
<returntype="number">of relative index of the element to its parent (starting from 0)</return>
<paramname="locator">an <ahref="#locators">element locator</a> pointing to an element</param>
<comment>Get the relative index of an element to its parent (starting from 0). The comment node and empty text node
<returntype="number">of pixels from the edge of the frame.</return>
<paramname="locator">an <ahref="#locators">element locator</a> pointing to an element OR an element itself</param>
<comment>Retrieves the horizontal position of an element</comment>
</function>
<functionname="getElementPositionTop">
<returntype="number">of pixels from the edge of the frame.</return>
<paramname="locator">an <ahref="#locators">element locator</a> pointing to an element OR an element itself</param>
<comment>Retrieves the vertical position of an element</comment>
</function>
<functionname="getElementWidth">
<returntype="number">width of an element in pixels</return>
<paramname="locator">an <ahref="#locators">element locator</a> pointing to an element</param>
<comment>Retrieves the width of an element</comment>
</function>
<functionname="getElementHeight">
<returntype="number">height of an element in pixels</return>
<paramname="locator">an <ahref="#locators">element locator</a> pointing to an element</param>
<comment>Retrieves the height of an element</comment>
</function>
<functionname="getCursorPosition">
<returntype="number">the numerical position of the cursor in the field</return>
<paramname="locator">an <ahref="#locators">element locator</a> pointing to an input element or textarea</param>
<comment>Retrieves the text cursor position in the given input element or textarea; beware, this may not work perfectly on all browsers.
<p>Specifically, if the cursor/selection has been cleared by JavaScript, this command will tend to
return the position of the last location of the cursor, even though the cursor is now gone from the page. This is filed as <ahref="http://jira.openqa.org/browse/SEL-243">SEL-243</a>.</p>
This method will fail if the specified element isn't an input element or textarea, or there is no cursor in the element.</comment>
<paramname="allow">boolean, true means we'll prefer to use native XPath; false means we'll only use JS XPath</param>
<comment>Specifies whether Selenium should use the native in-browser implementation
of XPath (if any native version is available); if you pass "false" to
this function, we will always use our pure-JavaScript xpath library.
Using the pure-JS xpath library can improve the consistency of xpath
element locators between different browser vendors, but the pure-JS
version is much slower than the native implementations.</comment>
</function>
<functionname="ignoreAttributesWithoutValue">
<paramname="ignore">boolean, true means we'll ignore attributes without value at the expense of xpath "correctness"; false means we'll sacrifice speed for correctness.</param>
<comment>Specifies whether Selenium will ignore xpath attributes that have no
value, i.e. are the empty string, when using the non-native xpath
evaluation engine. You'd want to do this for performance reasons in IE.
However, this could break certain xpaths, for example an xpath that looks
for an attribute whose value is NOT the empty string.
The hope is that such xpaths are relatively rare, but the user should
have the option of using them. Note that this only influences xpath
evaluation when using the ajaxslt engine (i.e. not "javascript-xpath").</comment>
<paramname="optionsString">options for the cookie. Currently supported options include 'path', 'max_age' and 'domain'. the optionsString's format is "path=/path/, max_age=60, domain=.foo.com". The order of options are irrelevant, the unit of the value of 'max_age' is second. Note that specifying a domain that isn't a subset of the current domain will usually fail.</param>
<paramname="optionsString">options for the cookie. Currently supported options include 'path', 'domain' and 'recurse.' The optionsString's format is "path=/path/, domain=.foo.com, recurse=true". The order of options are irrelevant. Note that specifying a domain that isn't a subset of the current domain will usually fail.</param>
<comment>Delete a named cookie with specified path and domain. Be careful; to delete a cookie, you
need to delete it using the exact same path and domain that were used to create the cookie.
If the path is wrong, or the domain is wrong, the cookie simply won't be deleted. Also
note that specifying a domain that isn't a subset of the current domain will usually fail.
Since there's no way to discover at runtime the original path and domain of a given cookie,
we've added an option called 'recurse' to try all sub-domains of the current domain with
all paths that are a subset of the current path. Beware; this option can be slow. In
big-O notation, it operates in O(n*m) time, where n is the number of dots in the domain
name and m is the number of slashes in the path.</comment>
</function>
<functionname="deleteAllVisibleCookies">
<comment>Calls deleteCookie with recurse=true on all cookies visible to the current page.
As noted on the documentation for deleteCookie, recurse=true can be much slower
than simply deleting the cookies using a known domain/path.</comment>
</function>
<functionname="setBrowserLogLevel">
<paramname="logLevel">one of the following: "debug", "info", "warn", "error" or "off"</param>
<comment>Sets the threshold for browser-side logging messages; log messages beneath this threshold will be discarded.
Valid logLevel strings are: "debug", "info", "warn", "error" or "off".
To see the browser logs, you need to
either show the log window in GUI mode, or enable browser-side logging in Selenium RC.</comment>
</function>
<functionname="runScript">
<paramname="script">the JavaScript snippet to run</param>
<comment>Creates a new "script" tag in the body of the current test window, and
adds the specified text into the body of the command. Scripts run in
this way can often be debugged more easily than scripts executed using
Selenium's "getEval" command. Beware that JS exceptions thrown in these script
tags aren't managed by Selenium, so you should probably wrap your script
in try/catch blocks if there is any chance that the script will throw
an exception.</comment>
</function>
<functionname="addLocationStrategy">
<paramname="strategyName">the name of the strategy to define; this should use only letters [a-zA-Z] with no spaces or other punctuation.</param>
<paramname="functionDefinition">a string defining the body of a function in JavaScript. For example: <code>return inDocument.getElementById(locator);</code></param>
<comment>Defines a new function for Selenium to locate elements on the page.
For example,
if you define the strategy "foo", and someone runs click("foo=blah"), we'll
run your function, passing you the string "blah", and click on the element
that your function
returns, or throw an "Element not found" error if your function returns null.
We'll pass three arguments to your function:
<ul>
<li>locator: the string the user passed in</li>
<li>inWindow: the currently selected window</li>
<li>inDocument: the currently selected document</li>
</ul>
The function must return null if the element can't be found.</comment>
</function>
<functionname="captureEntirePageScreenshot">
<paramname="filename">the path to the file to persist the screenshot as. No filename extension will be appended by default. Directories will not be created if they do not exist, and an exception will be thrown, possibly by native code.</param>
<paramname="kwargs">a kwargs string that modifies the way the screenshot is captured. Example: "background=#CCFFDD" . Currently valid options: <dl><dt>background</dt><dd>the background CSS for the HTML document. This may be useful to set for capturing screenshots of less-than-ideal layouts, for example where absolute positioning causes the calculation of the canvas dimension to fail and a black background is exposed (possibly obscuring black text).</dd></dl></param>
<comment>Saves the entire contents of the current window canvas to a PNG file.
Contrast this with the captureScreenshot command, which captures the
contents of the OS viewport (i.e. whatever is currently being displayed
on the monitor), and is implemented in the RC only. Currently this only
works in Firefox when running in chrome mode, and in IE non-HTA using
the EXPERIMENTAL "Snapsie" utility. The Firefox implementation is mostly
borrowed from the Screengrab! Firefox extension. Please see
http://www.screengrab.org and http://snapsie.sourceforge.net/ for
details.</comment>
</function>
<functionname="rollup">
<paramname="rollupName">the name of the rollup command</param>
<paramname="kwargs">keyword arguments string that influences how the rollup expands into commands</param>
<comment>Executes a command rollup, which is a series of commands with a unique
name, and optionally arguments that control the generation of the set of
commands. If any one of the rolled-up commands fails, the rollup is
considered to have failed. Rollups may also contain nested rollups.</comment>
</function>
<functionname="addScript">
<paramname="scriptContent">the Javascript content of the script to add</param>
<paramname="scriptTagId">(optional) the id of the new script tag. If specified, and an element with this id already exists, this operation will fail.</param>
<comment>Loads script content into a new script tag in the Selenium document. This
differs from the runScript command in that runScript adds the script tag
to the document of the AUT, not the Selenium document. The following
entities in the script content are replaced by the characters they
represent:
<
>
&
The corresponding remove command is removeScript.</comment>
</function>
<functionname="removeScript">
<paramname="scriptTagId">the id of the script element to remove.</param>
<comment>Removes a script tag from the Selenium document identified by the given
id. Does nothing if the referenced tag doesn't exist.</comment>
</function>
<functionname="useXpathLibrary">
<paramname="libraryName">name of the desired library Only the following three can be chosen: ajaxslt - Google's library javascript - Cybozu Labs' faster library default - The default library. Currently the default library is ajaxslt. If libraryName isn't one of these three, then no change will be made.</param>
<comment>Allows choice of one of the available libraries.</comment>
</function>
<functionname="setContext">
<paramname="context">the message to be sent to the browser</param>
<comment>Writes a message to the status bar and adds a note to the browser-side
<paramname="fileLocator">a URL pointing to the specified file. Before the file can be set in the input field (fieldLocator), Selenium RC may need to transfer the file to the local machine before attaching the file in a web page form. This is common in selenium grid configurations where the RC server driving the browser is not the same machine that started the test. Supported Browsers: Firefox ("*chrome") only.</param>
<comment>Sets a file input (upload) field to the file listed in fileLocator</comment>
</function>
<functionname="captureScreenshot">
<paramname="filename">the absolute path to the file to be written, e.g. "c:\blah\screenshot.png"</param>
<comment>Captures a PNG screenshot to the specified file.</comment>
</function>
<functionname="captureScreenshotToString">
<returntype="string">The base 64 encoded string of the screen shot (PNG file)</return>
<comment>Capture a PNG screenshot. It then returns the file as a base 64 encoded string.</comment>
<returntype="string">The base 64 encoded string of the page screenshot (PNG file)</return>
<paramname="kwargs">A kwargs string that modifies the way the screenshot is captured. Example: "background=#CCFFDD". This may be useful to set for capturing screenshots of less-than-ideal layouts, for example where absolute positioning causes the calculation of the canvas dimension to fail and a black background is exposed (possibly obscuring black text).</param>
<comment>Downloads a screenshot of the browser current window canvas to a
based 64 encoded PNG file. The <em>entire</em> windows canvas is captured,
including parts rendered outside of the current view port.
Currently this only works in Mozilla and when running in chrome mode.</comment>
</function>
<functionname="shutDownSeleniumServer">
<comment>Kills the running Selenium Server and all browser sessions. After you run this command, you will no longer be able to send
commands to the server; you can't remotely start the server once it has been stopped. Normally
you should prefer to run the "stop" command, which terminates the current browser session, rather than
shutting down the entire server.</comment>
</function>
<functionname="retrieveLastRemoteControlLogs">
<returntype="string">The last N log messages as a multi-line string.</return>
<comment>Retrieve the last messages logged on a specific remote control. Useful for error reports, especially
when running multiple remote controls in a distributed environment. The maximum number of log messages
that can be retrieve is configured on remote control startup.</comment>
</function>
<functionname="keyDownNative">
<paramname="keycode">an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes!</param>
<comment>Simulates a user pressing a key (without releasing it yet) by sending a native operating system keystroke.
This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing
a key on the keyboard. It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and
metaKeyDown commands, and does not target any particular HTML element. To send a keystroke to a particular
element, focus on the element first before running this command.</comment>
</function>
<functionname="keyUpNative">
<paramname="keycode">an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes!</param>
<comment>Simulates a user releasing a key by sending a native operating system keystroke.
This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing
a key on the keyboard. It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and
metaKeyDown commands, and does not target any particular HTML element. To send a keystroke to a particular
element, focus on the element first before running this command.</comment>
</function>
<functionname="keyPressNative">
<paramname="keycode">an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes!</param>