1
<?xml version="1.0" encoding="UTF-8"?>
5
<top>Defines an object that runs Selenium commands.
7
<h3><a name="locators"></a>Element Locators</h3>
9
Element Locators tell Selenium which HTML element a command refers to.
10
The format of a locator is:</p>
12
<em>locatorType</em><strong>=</strong><em>argument</em>
16
We support the following strategies for locating elements:
20
<li><strong>identifier</strong>=<em>id</em>:
21
Select the element with the specified @id attribute. If no match is
22
found, select the first element whose @name attribute is <em>id</em>.
23
(This is normally the default; see below.)</li>
24
<li><strong>id</strong>=<em>id</em>:
25
Select the element with the specified @id attribute.</li>
27
<li><strong>name</strong>=<em>name</em>:
28
Select the first element with the specified @name attribute.
29
<ul class="first last simple">
31
<li>name=username</li>
34
<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>
36
<ul class="first last simple">
37
<li>name=flavour value=chocolate</li>
40
<li><strong>dom</strong>=<em>javascriptExpression</em>:
42
Find an element by evaluating the specified string. This allows you to traverse the HTML Document Object
43
Model using JavaScript. Note that you must not return a value in this string; simply make it the last expression in the block.
44
<ul class="first last simple">
45
<li>dom=document.forms['myForm'].myDropdown</li>
46
<li>dom=document.images[56]</li>
47
<li>dom=function foo() { return document.links[1]; }; foo();</li>
52
<li><strong>xpath</strong>=<em>xpathExpression</em>:
53
Locate an element using an XPath expression.
54
<ul class="first last simple">
55
<li>xpath=//img[@alt='The image alt text']</li>
56
<li>xpath=//table[@id='table1']//tr[4]/td[2]</li>
57
<li>xpath=//a[contains(@href,'#id1')]</li>
58
<li>xpath=//a[contains(@href,'#id1')]/@class</li>
59
<li>xpath=(//table[@class='stylee'])//th[text()='theHeaderText']/../td</li>
60
<li>xpath=//input[@name='name2' and @value='yes']</li>
61
<li>xpath=//*[text()="right"]</li>
65
<li><strong>link</strong>=<em>textPattern</em>:
66
Select the link (anchor) element which contains text matching the
67
specified <em>pattern</em>.
68
<ul class="first last simple">
69
<li>link=The link text</li>
74
<li><strong>css</strong>=<em>cssSelectorSyntax</em>:
75
Select the element using css selectors. Please refer to <a href="http://www.w3.org/TR/REC-CSS2/selector.html">CSS2 selectors</a>, <a href="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.
76
<ul class="first last simple">
77
<li>css=a[href="#id3"]</li>
78
<li>css=span#firstChild + span</li>
80
<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>
85
Without an explicit locator prefix, Selenium uses the following default
90
<li><strong>dom</strong>, for locators starting with "document."</li>
91
<li><strong>xpath</strong>, for locators starting with "//"</li>
92
<li><strong>identifier</strong>, otherwise</li>
95
<h3><a name="element-filters">Element Filters</a></h3>
97
<p>Element filters can be used with a locator to refine a list of candidate elements. They are currently used only in the 'name' element-locator.</p>
98
<p>Filters look much like locators, ie.</p>
100
<em>filterType</em><strong>=</strong><em>argument</em></blockquote>
102
<p>Supported element-filters are:</p>
103
<p><strong>value=</strong><em>valuePattern</em></p>
105
Matches elements based on their values. This is particularly useful for refining a list of similarly-named toggle-buttons.</blockquote>
106
<p><strong>index=</strong><em>index</em></p>
108
Selects a single element based on its position in the list (offset from zero).</blockquote>
111
<h3><a name="patterns"></a>String-match Patterns</h3>
114
Various Pattern syntaxes are available for matching string values:
117
<li><strong>glob:</strong><em>pattern</em>:
118
Match a string against a "glob" (aka "wildmat") pattern. "Glob" is a
119
kind of limited regular-expression syntax typically used in command-line
120
shells. In a glob pattern, "*" represents any sequence of characters, and "?"
121
represents any single character. Glob patterns match against the entire
123
<li><strong>regexp:</strong><em>regexp</em>:
124
Match a string using a regular-expression. The full power of JavaScript
125
regular-expressions is available.</li>
126
<li><strong>exact:</strong><em>string</em>:
128
Match a string exactly, verbatim, without any of that fancy wildcard
132
If no pattern prefix is specified, Selenium assumes that it's a "glob"
136
<function name="click">
138
<param name="locator">an element locator</param>
140
<comment>Clicks on a link, button, checkbox or radio button. If the click action
141
causes a new page to load (like a link usually does), call
142
waitForPageToLoad.</comment>
146
<function name="doubleClick">
148
<param name="locator">an element locator</param>
150
<comment>Double clicks on a link, button, checkbox or radio button. If the double click action
151
causes a new page to load (like a link usually does), call
152
waitForPageToLoad.</comment>
156
<function name="clickAt">
158
<param name="locator">an element locator</param>
160
<param name="coordString">specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.</param>
162
<comment>Clicks on a link, button, checkbox or radio button. If the click action
163
causes a new page to load (like a link usually does), call
164
waitForPageToLoad.</comment>
168
<function name="doubleClickAt">
170
<param name="locator">an element locator</param>
172
<param name="coordString">specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.</param>
174
<comment>Doubleclicks on a link, button, checkbox or radio button. If the action
175
causes a new page to load (like a link usually does), call
176
waitForPageToLoad.</comment>
180
<function name="fireEvent">
182
<param name="locator">an <a href="#locators">element locator</a></param>
184
<param name="eventName">the event name, e.g. "focus" or "blur"</param>
186
<comment>Explicitly simulate an event, to trigger the corresponding "on<em>event</em>"
191
<function name="keyPress">
193
<param name="locator">an <a href="#locators">element locator</a></param>
195
<param name="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>
197
<comment>Simulates a user pressing and releasing a key.</comment>
201
<function name="shiftKeyDown">
203
<comment>Press the shift key and hold it down until doShiftUp() is called or a new page is loaded.</comment>
207
<function name="shiftKeyUp">
209
<comment>Release the shift key.</comment>
213
<function name="metaKeyDown">
215
<comment>Press the meta key and hold it down until doMetaUp() is called or a new page is loaded.</comment>
219
<function name="metaKeyUp">
221
<comment>Release the meta key.</comment>
225
<function name="altKeyDown">
227
<comment>Press the alt key and hold it down until doAltUp() is called or a new page is loaded.</comment>
231
<function name="altKeyUp">
233
<comment>Release the alt key.</comment>
237
<function name="controlKeyDown">
239
<comment>Press the control key and hold it down until doControlUp() is called or a new page is loaded.</comment>
243
<function name="controlKeyUp">
245
<comment>Release the control key.</comment>
249
<function name="keyDown">
251
<param name="locator">an <a href="#locators">element locator</a></param>
253
<param name="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>
255
<comment>Simulates a user pressing a key (without releasing it yet).</comment>
259
<function name="keyUp">
261
<param name="locator">an <a href="#locators">element locator</a></param>
263
<param name="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>
265
<comment>Simulates a user releasing a key.</comment>
269
<function name="mouseOver">
271
<param name="locator">an <a href="#locators">element locator</a></param>
273
<comment>Simulates a user hovering a mouse over the specified element.</comment>
277
<function name="mouseOut">
279
<param name="locator">an <a href="#locators">element locator</a></param>
281
<comment>Simulates a user moving the mouse pointer away from the specified element.</comment>
285
<function name="mouseDown">
287
<param name="locator">an <a href="#locators">element locator</a></param>
289
<comment>Simulates a user pressing the mouse button (without releasing it yet) on
290
the specified element.</comment>
294
<function name="mouseDownAt">
296
<param name="locator">an <a href="#locators">element locator</a></param>
298
<param name="coordString">specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.</param>
300
<comment>Simulates a user pressing the mouse button (without releasing it yet) on
301
the specified element.</comment>
305
<function name="mouseUp">
307
<param name="locator">an <a href="#locators">element locator</a></param>
309
<comment>Simulates a user pressing the mouse button (without releasing it yet) on
310
the specified element.</comment>
314
<function name="mouseUpAt">
316
<param name="locator">an <a href="#locators">element locator</a></param>
318
<param name="coordString">specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.</param>
320
<comment>Simulates a user pressing the mouse button (without releasing it yet) on
321
the specified element.</comment>
325
<function name="mouseMove">
327
<param name="locator">an <a href="#locators">element locator</a></param>
329
<comment>Simulates a user pressing the mouse button (without releasing it yet) on
330
the specified element.</comment>
334
<function name="mouseMoveAt">
336
<param name="locator">an <a href="#locators">element locator</a></param>
338
<param name="coordString">specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.</param>
340
<comment>Simulates a user pressing the mouse button (without releasing it yet) on
341
the specified element.</comment>
345
<function name="type">
347
<param name="locator">an <a href="#locators">element locator</a></param>
349
<param name="value">the value to type</param>
351
<comment>Sets the value of an input field, as though you typed it in.
353
<p>Can also be used to set the value of combo boxes, check boxes, etc. In these cases,
354
value should be the value of the option selected, not the visible text.</p></comment>
358
<function name="typeKeys">
360
<param name="locator">an <a href="#locators">element locator</a></param>
362
<param name="value">the value to type</param>
364
<comment>Simulates keystroke events on the specified element, as though you typed the value key-by-key.
366
<p>This is a convenience method for calling keyDown, keyUp, keyPress for every character in the specified string;
367
this is useful for dynamic UI widgets (like auto-completing combo boxes) that require explicit key events.</p>
369
<p>Unlike the simple "type" command, which forces the specified value into the page directly, this command
370
may or may not have any visible effect, even in cases where typing keys would normally have a visible effect.
371
For example, if you use "typeKeys" on a form element, you may or may not see the results of what you typed in
373
<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
374
send the keystroke events corresponding to what you just typed.</p></comment>
378
<function name="setSpeed">
380
<param name="value">the number of milliseconds to pause after operation</param>
382
<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.,
383
the delay is 0 milliseconds.</comment>
387
<function name="getSpeed">
389
<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.,
390
the delay is 0 milliseconds.
392
See also setSpeed.</comment>
396
<function name="check">
398
<param name="locator">an <a href="#locators">element locator</a></param>
400
<comment>Check a toggle-button (checkbox/radio)</comment>
404
<function name="uncheck">
406
<param name="locator">an <a href="#locators">element locator</a></param>
408
<comment>Uncheck a toggle-button (checkbox/radio)</comment>
412
<function name="select">
414
<param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
416
<param name="optionLocator">an option locator (a label by default)</param>
418
<comment>Select an option from a drop-down using an option locator.
421
Option locators provide different ways of specifying options of an HTML
422
Select element (e.g. for selecting a specific option, or for asserting
423
that the selected option satisfies a specification). There are several
424
forms of Select Option Locator.
427
<li><strong>label</strong>=<em>labelPattern</em>:
428
matches options based on their labels, i.e. the visible text. (This
430
<ul class="first last simple">
431
<li>label=regexp:^[Oo]ther</li>
434
<li><strong>value</strong>=<em>valuePattern</em>:
435
matches options based on their values.
436
<ul class="first last simple">
442
<li><strong>id</strong>=<em>id</em>:
444
matches options based on their ids.
445
<ul class="first last simple">
449
<li><strong>index</strong>=<em>index</em>:
450
matches an option based on its index (offset from zero).
451
<ul class="first last simple">
458
If no option locator prefix is provided, the default behaviour is to match on <strong>label</strong>.
463
<function name="addSelection">
465
<param name="locator">an <a href="#locators">element locator</a> identifying a multi-select box</param>
467
<param name="optionLocator">an option locator (a label by default)</param>
469
<comment>Add a selection to the set of selected options in a multi-select element using an option locator.
471
@see #doSelect for details of option locators</comment>
475
<function name="removeSelection">
477
<param name="locator">an <a href="#locators">element locator</a> identifying a multi-select box</param>
479
<param name="optionLocator">an option locator (a label by default)</param>
481
<comment>Remove a selection from the set of selected options in a multi-select element using an option locator.
483
@see #doSelect for details of option locators</comment>
487
<function name="removeAllSelections">
489
<param name="locator">an <a href="#locators">element locator</a> identifying a multi-select box</param>
491
<comment>Unselects all of the selected options in a multi-select element.</comment>
495
<function name="submit">
497
<param name="formLocator">an <a href="#locators">element locator</a> for the form you want to submit</param>
499
<comment>Submit the specified form. This is particularly useful for forms without
500
submit buttons, e.g. single-input "Search" forms.</comment>
504
<function name="open">
506
<param name="url">the URL to open; may be relative or absolute</param>
508
<comment>Opens an URL in the test frame. This accepts both relative and absolute
511
The "open" command waits for the page to load before proceeding,
512
ie. the "AndWait" suffix is implicit.
514
<em>Note</em>: The URL must be on the same domain as the runner HTML
515
due to security restrictions in the browser (Same Origin Policy). If you
516
need to open an URL on another domain, use the Selenium Server to start a
517
new browser session on that domain.</comment>
521
<function name="openWindow">
523
<param name="url">the URL to open, which can be blank</param>
525
<param name="windowID">the JavaScript window ID of the window to select</param>
527
<comment>Opens a popup window (if a window with that ID isn't already open).
528
After opening the window, you'll need to select it using the selectWindow
531
<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).
532
In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using
533
an empty (blank) url, like this: openWindow("", "myFunnyWindow").</p></comment>
537
<function name="selectWindow">
539
<param name="windowID">the JavaScript window ID of the window to select</param>
541
<comment>Selects a popup window; once a popup window has been selected, all
542
commands go to that window. To select the main window again, use null
545
<p>Selenium has several strategies for finding the window object referred to by the "windowID" parameter.</p>
547
<p>1.) if windowID is null, then it is assumed the user is referring to the original window instantiated by the browser).</p>
548
<p>2.) if the value of the "windowID" parameter is a JavaScript variable name in the current application window, then it is assumed
549
that this variable contains the return value from a call to the JavaScript window.open() method.</p>
550
<p>3.) Otherwise, selenium looks in a hash it maintains that maps string names to window objects. Each of these string
551
names matches the second parameter "windowName" past to the JavaScript method window.open(url, windowName, windowFeatures, replaceFlag)
552
(which selenium intercepts).</p>
554
<p>If you're having trouble figuring out what is the name of a window that you want to manipulate, look at the selenium log messages
555
which identify the names of windows created via window.open (and therefore intercepted by selenium). You will see messages
556
like the following for each window as it is opened:</p>
558
<p><code>debug: window.open call intercepted; window ID (which you can use with selectWindow()) is "myNewWindow"</code></p>
560
<p>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).
561
(This is bug SEL-339.) In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using
562
an empty (blank) url, like this: openWindow("", "myFunnyWindow").</p></comment>
566
<function name="selectFrame">
568
<param name="locator">an <a href="#locators">element locator</a> identifying a frame or iframe</param>
570
<comment>Selects a frame within the current window. (You may invoke this command
571
multiple times to select nested frames.) To select the parent frame, use
572
"relative=parent" as a locator; to select the top frame, use "relative=top".
574
<p>You may also use a DOM expression to identify the frame you want directly,
575
like this: <code>dom=frames["main"].frames["subframe"]</code></p></comment>
579
<function name="getLogMessages">
581
<return type="string">all log messages seen since the last call to this API</return>
583
<comment>Return the contents of the log.
585
<p>This is a placeholder intended to make the code generator make this API
586
available to clients. The selenium server will intercept this call, however,
587
and return its recordkeeping of log messages since the last call to this API.
588
Thus this code in JavaScript will never be called.</p>
590
<p>The reason I opted for a servercentric solution is to be able to support
591
multiple frames served from different domains, which would break a
592
centralized JavaScript logging mechanism under some conditions.</p></comment>
596
<function name="getWhetherThisFrameMatchFrameExpression">
598
<return type="boolean">true if the new frame is this code's window</return>
600
<param name="currentFrameString">starting frame</param>
602
<param name="target">new frame (which might be relative to the current one)</param>
604
<comment>Determine whether current/locator identify the frame containing this running code.
606
<p>This is useful in proxy injection mode, where this code runs in every
607
browser frame and window, and sometimes the selenium server needs to identify
608
the "current" frame. In this case, when the test calls selectFrame, this
609
routine is called for each frame to figure out which one has been selected.
610
The selected frame will return true, while all others will return false.</p></comment>
614
<function name="getWhetherThisWindowMatchWindowExpression">
616
<return type="boolean">true if the new window is this code's window</return>
618
<param name="currentWindowString">starting window</param>
620
<param name="target">new window (which might be relative to the current one, e.g., "_parent")</param>
622
<comment>Determine whether currentWindowString plus target identify the window containing this running code.
624
<p>This is useful in proxy injection mode, where this code runs in every
625
browser frame and window, and sometimes the selenium server needs to identify
626
the "current" window. In this case, when the test calls selectWindow, this
627
routine is called for each window to figure out which one has been selected.
628
The selected window will return true, while all others will return false.</p></comment>
632
<function name="waitForPopUp">
634
<param name="windowID">the JavaScript window ID of the window that will appear</param>
636
<param name="timeout">a timeout in milliseconds, after which the action will return with an error</param>
638
<comment>Waits for a popup window to appear and load up.</comment>
642
<function name="chooseCancelOnNextConfirmation">
644
<comment>By default, Selenium's overridden window.confirm() function will
645
return true, as if the user had manually clicked OK. After running
646
this command, the next call to confirm() will return false, as if
647
the user had clicked Cancel.</comment>
651
<function name="answerOnNextPrompt">
653
<param name="answer">the answer to give in response to the prompt pop-up</param>
655
<comment>Instructs Selenium to return the specified answer string in response to
656
the next JavaScript prompt [window.prompt()].</comment>
660
<function name="goBack">
662
<comment>Simulates the user clicking the "back" button on their browser.</comment>
666
<function name="refresh">
668
<comment>Simulates the user clicking the "Refresh" button on their browser.</comment>
672
<function name="close">
674
<comment>Simulates the user clicking the "close" button in the titlebar of a popup
675
window or tab.</comment>
679
<function name="isAlertPresent">
681
<return type="boolean">true if there is an alert</return>
683
<comment>Has an alert occurred?
686
This function never throws an exception
691
<function name="isPromptPresent">
693
<return type="boolean">true if there is a pending prompt</return>
695
<comment>Has a prompt occurred?
698
This function never throws an exception
703
<function name="isConfirmationPresent">
705
<return type="boolean">true if there is a pending confirmation</return>
707
<comment>Has confirm() been called?
710
This function never throws an exception
715
<function name="getAlert">
717
<return type="string">The message of the most recent JavaScript alert</return>
719
<comment>Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts.
721
<p>Getting an alert has the same effect as manually clicking OK. If an
722
alert is generated but you do not get/verify it, the next Selenium action
725
<p>NOTE: under Selenium, JavaScript alerts will NOT pop up a visible alert
728
<p>NOTE: Selenium does NOT support JavaScript alerts that are generated in a
729
page's onload() event handler. In this case a visible dialog WILL be
730
generated and Selenium will hang until someone manually clicks OK.</p></comment>
734
<function name="getConfirmation">
736
<return type="string">the message of the most recent JavaScript confirmation dialog</return>
738
<comment>Retrieves the message of a JavaScript confirmation dialog generated during
742
By default, the confirm function will return true, having the same effect
743
as manually clicking OK. This can be changed by prior execution of the
744
chooseCancelOnNextConfirmation command. If an confirmation is generated
745
but you do not get/verify it, the next Selenium action will fail.
749
NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible
754
NOTE: Selenium does NOT support JavaScript confirmations that are
755
generated in a page's onload() event handler. In this case a visible
756
dialog WILL be generated and Selenium will hang until you manually click
762
<function name="getPrompt">
764
<return type="string">the message of the most recent JavaScript question prompt</return>
766
<comment>Retrieves the message of a JavaScript question prompt dialog generated during
769
<p>Successful handling of the prompt requires prior execution of the
770
answerOnNextPrompt command. If a prompt is generated but you
771
do not get/verify it, the next Selenium action will fail.</p>
773
<p>NOTE: under Selenium, JavaScript prompts will NOT pop up a visible
776
<p>NOTE: Selenium does NOT support JavaScript prompts that are generated in a
777
page's onload() event handler. In this case a visible dialog WILL be
778
generated and Selenium will hang until someone manually clicks OK.</p></comment>
782
<function name="getLocation">
784
<return type="string">the absolute URL of the current page</return>
786
<comment>Gets the absolute URL of the current page.</comment>
790
<function name="getTitle">
792
<return type="string">the title of the current page</return>
794
<comment>Gets the title of the current page.</comment>
798
<function name="getBodyText">
800
<return type="string">the entire text of the page</return>
802
<comment>Gets the entire text of the page.</comment>
806
<function name="getValue">
808
<return type="string">the element value, or "on/off" for checkbox/radio elements</return>
810
<param name="locator">an <a href="#locators">element locator</a></param>
812
<comment>Gets the (whitespace-trimmed) value of an input field (or anything else with a value parameter).
813
For checkbox/radio elements, the value will be "on" or "off" depending on
814
whether the element is checked or not.</comment>
818
<function name="getText">
820
<return type="string">the text of the element</return>
822
<param name="locator">an <a href="#locators">element locator</a></param>
824
<comment>Gets the text of an element. This works for any element that contains
825
text. This command uses either the textContent (Mozilla-like browsers) or
826
the innerText (IE-like browsers) of the element, which is the rendered
827
text shown to the user.</comment>
831
<function name="highlight">
833
<param name="locator">an <a href="#locators">element locator</a></param>
835
<comment>Briefly changes the backgroundColor of the specified element yellow. Useful for debugging.</comment>
839
<function name="getEval">
841
<return type="string">the results of evaluating the snippet</return>
843
<param name="script">the JavaScript snippet to run</param>
845
<comment>Gets the result of evaluating the specified JavaScript snippet. The snippet may
846
have multiple lines, but only the result of the last line will be returned.
848
<p>Note that, by default, the snippet will run in the context of the "selenium"
849
object itself, so <code>this</code> will refer to the Selenium object, and <code>window</code> will
850
refer to the top-level runner test window, not the window of your application.</p>
852
<p>If you need a reference to the window of your application, you can refer
853
to <code>this.browserbot.getCurrentWindow()</code> and if you need to use
854
a locator to refer to a single element in your application page, you can
855
use <code>this.browserbot.findElement("foo")</code> where "foo" is your locator.</p></comment>
859
<function name="isChecked">
861
<return type="boolean">true if the checkbox is checked, false otherwise</return>
863
<param name="locator">an <a href="#locators">element locator</a> pointing to a checkbox or radio button</param>
865
<comment>Gets whether a toggle-button (checkbox/radio) is checked. Fails if the specified element doesn't exist or isn't a toggle-button.</comment>
869
<function name="getTable">
871
<return type="string">the text from the specified cell</return>
873
<param name="tableCellAddress">a cell address, e.g. "foo.1.4"</param>
875
<comment>Gets the text from a cell of a table. The cellAddress syntax
876
tableLocator.row.column, where row and column start at 0.</comment>
880
<function name="getSelectedLabels">
882
<return type="string[]">an array of all selected option labels in the specified select drop-down</return>
884
<param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
886
<comment>Gets all option labels (visible text) for selected options in the specified select or multi-select element.</comment>
890
<function name="getSelectedLabel">
892
<return type="string">the selected option label in the specified select drop-down</return>
894
<param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
896
<comment>Gets option label (visible text) for selected option in the specified select element.</comment>
900
<function name="getSelectedValues">
902
<return type="string[]">an array of all selected option values in the specified select drop-down</return>
904
<param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
906
<comment>Gets all option values (value attributes) for selected options in the specified select or multi-select element.</comment>
910
<function name="getSelectedValue">
912
<return type="string">the selected option value in the specified select drop-down</return>
914
<param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
916
<comment>Gets option value (value attribute) for selected option in the specified select element.</comment>
920
<function name="getSelectedIndexes">
922
<return type="string[]">an array of all selected option indexes in the specified select drop-down</return>
924
<param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
926
<comment>Gets all option indexes (option number, starting at 0) for selected options in the specified select or multi-select element.</comment>
930
<function name="getSelectedIndex">
932
<return type="string">the selected option index in the specified select drop-down</return>
934
<param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
936
<comment>Gets option index (option number, starting at 0) for selected option in the specified select element.</comment>
940
<function name="getSelectedIds">
942
<return type="string[]">an array of all selected option IDs in the specified select drop-down</return>
944
<param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
946
<comment>Gets all option element IDs for selected options in the specified select or multi-select element.</comment>
950
<function name="getSelectedId">
952
<return type="string">the selected option ID in the specified select drop-down</return>
954
<param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
956
<comment>Gets option element ID for selected option in the specified select element.</comment>
960
<function name="isSomethingSelected">
962
<return type="boolean">true if some option has been selected, false otherwise</return>
964
<param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
966
<comment>Determines whether some option in a drop-down menu is selected.</comment>
970
<function name="getSelectOptions">
972
<return type="string[]">an array of all option labels in the specified select drop-down</return>
974
<param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
976
<comment>Gets all option labels in the specified select drop-down.</comment>
980
<function name="getAttribute">
982
<return type="string">the value of the specified attribute</return>
984
<param name="attributeLocator">an element locator followed by an</param>
986
<comment>Gets the value of an element attribute.</comment>
990
<function name="isTextPresent">
992
<return type="boolean">true if the pattern matches the text, false otherwise</return>
994
<param name="pattern">a <a href="#patterns">pattern</a> to match with the text of the page</param>
996
<comment>Verifies that the specified text pattern appears somewhere on the rendered page shown to the user.</comment>
1000
<function name="isElementPresent">
1002
<return type="boolean">true if the element is present, false otherwise</return>
1004
<param name="locator">an <a href="#locators">element locator</a></param>
1006
<comment>Verifies that the specified element is somewhere on the page.</comment>
1010
<function name="isVisible">
1012
<return type="boolean">true if the specified element is visible, false otherwise</return>
1014
<param name="locator">an <a href="#locators">element locator</a></param>
1016
<comment>Determines if the specified element is visible. An
1017
element can be rendered invisible by setting the CSS "visibility"
1018
property to "hidden", or the "display" property to "none", either for the
1019
element itself or one if its ancestors. This method will fail if
1020
the element is not present.</comment>
1024
<function name="isEditable">
1026
<return type="boolean">true if the input element is editable, false otherwise</return>
1028
<param name="locator">an <a href="#locators">element locator</a></param>
1030
<comment>Determines whether the specified input element is editable, ie hasn't been disabled.
1031
This method will fail if the specified element isn't an input element.</comment>
1035
<function name="getAllButtons">
1037
<return type="string[]">the IDs of all buttons on the page</return>
1039
<comment>Returns the IDs of all buttons on the page.
1041
<p>If a given button has no ID, it will appear as "" in this array.</p></comment>
1045
<function name="getAllLinks">
1047
<return type="string[]">the IDs of all links on the page</return>
1049
<comment>Returns the IDs of all links on the page.
1051
<p>If a given link has no ID, it will appear as "" in this array.</p></comment>
1055
<function name="getAllFields">
1057
<return type="string[]">the IDs of all field on the page</return>
1059
<comment>Returns the IDs of all input fields on the page.
1061
<p>If a given field has no ID, it will appear as "" in this array.</p></comment>
1065
<function name="getAttributeFromAllWindows">
1067
<return type="string[]">the set of values of this attribute from all known windows.</return>
1069
<param name="attributeName">name of an attribute on the windows</param>
1071
<comment>Returns every instance of some attribute from all known windows.</comment>
1075
<function name="dragdrop">
1077
<param name="locator">an element locator</param>
1079
<param name="movementsString">offset in pixels from the current location to which the element should be moved, e.g., "+70,-300"</param>
1081
<comment>deprecated - use dragAndDrop instead</comment>
1085
<function name="setMouseSpeed">
1087
<param name="pixels">the number of pixels between "mousemove" events</param>
1089
<comment>Configure the number of pixels between "mousemove" events during dragAndDrop commands (default=10).
1090
<p>Setting this value to 0 means that we'll send a "mousemove" event to every single pixel
1091
in between the start location and the end location; that can be very slow, and may
1092
cause some browsers to force the JavaScript to timeout.</p>
1094
<p>If the mouse speed is greater than the distance between the two dragged objects, we'll
1095
just send one "mousemove" at the start location and then one final one at the end location.</p></comment>
1099
<function name="getMouseSpeed">
1101
<return type="number">the number of pixels between "mousemove" events during dragAndDrop commands (default=10)</return>
1103
<comment>Returns the number of pixels between "mousemove" events during dragAndDrop commands (default=10).</comment>
1107
<function name="dragAndDrop">
1109
<param name="locator">an element locator</param>
1111
<param name="movementsString">offset in pixels from the current location to which the element should be moved, e.g., "+70,-300"</param>
1113
<comment>Drags an element a certain distance and then drops it</comment>
1117
<function name="dragAndDropToObject">
1119
<param name="locatorOfObjectToBeDragged">an element to be dragged</param>
1121
<param name="locatorOfDragDestinationObject">an element whose location (i.e., whose center-most pixel) will be the point where locatorOfObjectToBeDragged is dropped</param>
1123
<comment>Drags an element and drops it on another element</comment>
1127
<function name="windowFocus">
1129
<param name="windowName">name of the window to be given focus</param>
1131
<comment>Gives focus to a window</comment>
1135
<function name="windowMaximize">
1137
<param name="windowName">name of the window to be enlarged</param>
1139
<comment>Resize window to take up the entire screen</comment>
1143
<function name="getAllWindowIds">
1145
<return type="string[]">the IDs of all windows that the browser knows about.</return>
1147
<comment>Returns the IDs of all windows that the browser knows about.</comment>
1151
<function name="getAllWindowNames">
1153
<return type="string[]">the names of all windows that the browser knows about.</return>
1155
<comment>Returns the names of all windows that the browser knows about.</comment>
1159
<function name="getAllWindowTitles">
1161
<return type="string[]">the titles of all windows that the browser knows about.</return>
1163
<comment>Returns the titles of all windows that the browser knows about.</comment>
1167
<function name="getHtmlSource">
1169
<return type="string">the entire HTML source</return>
1171
<comment>Returns the entire HTML source between the opening and
1172
closing "html" tags.</comment>
1176
<function name="setCursorPosition">
1178
<param name="locator">an <a href="#locators">element locator</a> pointing to an input element or textarea</param>
1180
<param name="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>
1182
<comment>Moves the text cursor to the specified position in the given input element or textarea.
1183
This method will fail if the specified element isn't an input element or textarea.</comment>
1187
<function name="getElementIndex">
1189
<return type="number">of relative index of the element to its parent (starting from 0)</return>
1191
<param name="locator">an <a href="#locators">element locator</a> pointing to an element</param>
1193
<comment>Get the relative index of an element to its parent (starting from 0). The comment node and empty text node
1194
will be ignored.</comment>
1198
<function name="isOrdered">
1200
<return type="boolean">true if two elements are ordered and have same parent, false otherwise</return>
1202
<param name="locator1">an <a href="#locators">element locator</a> pointing to the first element</param>
1204
<param name="locator2">an <a href="#locators">element locator</a> pointing to the second element</param>
1206
<comment>Check if these two elements have same parent and are ordered. Two same elements will
1207
not be considered ordered.</comment>
1211
<function name="getElementPositionLeft">
1213
<return type="number">of pixels from the edge of the frame.</return>
1215
<param name="locator">an <a href="#locators">element locator</a> pointing to an element OR an element itself</param>
1217
<comment>Retrieves the horizontal position of an element</comment>
1221
<function name="getElementPositionTop">
1223
<return type="number">of pixels from the edge of the frame.</return>
1225
<param name="locator">an <a href="#locators">element locator</a> pointing to an element OR an element itself</param>
1227
<comment>Retrieves the vertical position of an element</comment>
1231
<function name="getElementWidth">
1233
<return type="number">width of an element in pixels</return>
1235
<param name="locator">an <a href="#locators">element locator</a> pointing to an element</param>
1237
<comment>Retrieves the width of an element</comment>
1241
<function name="getElementHeight">
1243
<return type="number">height of an element in pixels</return>
1245
<param name="locator">an <a href="#locators">element locator</a> pointing to an element</param>
1247
<comment>Retrieves the height of an element</comment>
1251
<function name="getCursorPosition">
1253
<return type="number">the numerical position of the cursor in the field</return>
1255
<param name="locator">an <a href="#locators">element locator</a> pointing to an input element or textarea</param>
1257
<comment>Retrieves the text cursor position in the given input element or textarea; beware, this may not work perfectly on all browsers.
1259
<p>Specifically, if the cursor/selection has been cleared by JavaScript, this command will tend to
1260
return the position of the last location of the cursor, even though the cursor is now gone from the page. This is filed as <a href="http://jira.openqa.org/browse/SEL-243">SEL-243</a>.</p>
1261
This method will fail if the specified element isn't an input element or textarea, or there is no cursor in the element.</comment>
1265
<function name="setContext">
1267
<param name="context">the message to be sent to the browser</param>
1269
<param name="logLevelThreshold">one of "debug", "info", "warn", "error", sets the threshold for browser-side logging</param>
1271
<comment>Writes a message to the status bar and adds a note to the browser-side
1274
<p>If logLevelThreshold is specified, set the threshold for logging
1275
to that level (debug, info, warn, error).</p>
1277
<p>(Note that the browser-side logs will <i>not</i> be sent back to the
1278
server, and are invisible to the Client Driver.)</p></comment>
1282
<function name="getExpression">
1284
<return type="string">the value passed in</return>
1286
<param name="expression">the value to return</param>
1288
<comment>Returns the specified expression.
1290
<p>This is useful because of JavaScript preprocessing.
1291
It is used to generate commands like assertExpression and waitForExpression.</p></comment>
1295
<function name="waitForCondition">
1297
<param name="script">the JavaScript snippet to run</param>
1299
<param name="timeout">a timeout in milliseconds, after which this command will return with an error</param>
1301
<comment>Runs the specified JavaScript snippet repeatedly until it evaluates to "true".
1302
The snippet may have multiple lines, but only the result of the last line
1305
<p>Note that, by default, the snippet will be run in the runner's test window, not in the window
1306
of your application. To get the window of your application, you can use
1307
the JavaScript snippet <code>selenium.browserbot.getCurrentWindow()</code>, and then
1308
run your JavaScript in there</p></comment>
1312
<function name="setTimeout">
1314
<param name="timeout">a timeout in milliseconds, after which the action will return with an error</param>
1316
<comment>Specifies the amount of time that Selenium will wait for actions to complete.
1318
<p>Actions that require waiting include "open" and the "waitFor*" actions.</p>
1319
The default timeout is 30 seconds.</comment>
1323
<function name="waitForPageToLoad">
1325
<param name="timeout">a timeout in milliseconds, after which this command will return with an error</param>
1327
<comment>Waits for a new page to load.
1329
<p>You can use this command instead of the "AndWait" suffixes, "clickAndWait", "selectAndWait", "typeAndWait" etc.
1330
(which are only available in the JS API).</p>
1332
<p>Selenium constantly keeps track of new pages loading, and sets a "newPageLoaded"
1333
flag when it first notices a page load. Running any other Selenium command after
1334
turns the flag to false. Hence, if you want to wait for a page to load, you must
1335
wait immediately after a Selenium command that caused a page-load.</p></comment>
1339
<function name="getCookie">
1341
<return type="string">all cookies of the current page under test</return>
1343
<comment>Return all cookies of the current page under test.</comment>
1347
<function name="createCookie">
1349
<param name="nameValuePair">name and value of the cookie in a format "name=value"</param>
1351
<param name="optionsString">options for the cookie. Currently supported options include 'path' and 'max_age'. the optionsString's format is "path=/path/, max_age=60". The order of options are irrelevant, the unit of the value of 'max_age' is second.</param>
1353
<comment>Create a new cookie whose path and domain are same with those of current page
1354
under test, unless you specified a path for this cookie explicitly.</comment>
1358
<function name="deleteCookie">
1360
<param name="name">the name of the cookie to be deleted</param>
1362
<param name="path">the path property of the cookie to be deleted</param>
1364
<comment>Delete a named cookie with specified path.</comment>
1368
<function name="pause">
1370
<param name="waitTime">the amount of time to sleep (in milliseconds)</param>
1372
<comment>Wait for the specified amount of time (in milliseconds)</comment>
1376
<function name="break">
1378
<comment>Halt the currently running test, and wait for the user to press the Continue button.
1379
This command is useful for debugging, but be careful when using it, because it will
1380
force automated tests to hang until a user intervenes manually.</comment>
1384
<function name="store">
1386
<param name="expression">the value to store</param>
1388
<param name="variableName">the name of a <a href="#storedVars">variable</a> in which the result is to be stored.</param>
1390
<comment>This command is a synonym for storeExpression.</comment>
1394
<function name="echo">
1396
<param name="message">the message to print</param>
1398
<comment>Prints the specified message into the third table cell in your Selenese tables.
1399
Useful for debugging.</comment>
1403
<function name="assertSelected">
1405
<param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
1407
<param name="optionLocator">an option locator, typically just an option label (e.g. "John Smith")</param>
1409
<comment>Verifies that the selected option of a drop-down satisfies the optionSpecifier. <i>Note that this command is deprecated; you should use assertSelectedLabel, assertSelectedValue, assertSelectedIndex, or assertSelectedId instead.</i>
1411
<p>See the select command for more information about option locators.</p></comment>
1415
<function name="assertFailureOnNext">
1417
<param name="message">The failure message we should expect. This command will fail if the wrong failure message appears.</param>
1419
<comment>Tell Selenium to expect a failure on the next command execution.</comment>
1423
<function name="assertErrorOnNext">
1425
<param name="message">The error message we should expect. This command will fail if the wrong error message appears.</param>
1427
<comment>Tell Selenium to expect an error on the next command execution.</comment>