Mozmill Element Object

  • Revision slug: Mozmill/Mozmill_Element_Object
  • Revision title: Mozmill Element Object
  • Revision id: 91910
  • Created:
  • Creator: ahal
  • Is current revision? No
  • Comment one or more formatting changes

Revision Content

This page is currently under development and is only relevant to Mozmill 2.0 and later.

When you manipulate DOM elements with Mozmill, you are actually using a wrapper object that wraps around the DOM element node. This wrapper object contains all the methods that are relevant to the actual DOM node. For example, if you obtain a 'button' element, you can expect to find a 'button.click()' method. If you have a 'menulist' element, you can expect a 'menulist.select()' method. Note that the 'select' method will not be available on, for example, a 'button' element.

The wrapper objects are set up as a hierarchy which can be extended and customized as you see fit (see extending the mozmill element hierarchy) . The base element contains all methods and properties that are common across all elements. Element types that have specific functionality sub-class this base class.

Element Method overview

All sub-classes of elements have these methods.

boolean click(int left, int top);
boolean doubleClick(int left, int top);
boolean rightClick(int left, int top);
boolean keypress(string keycode, object modifiers);
boolean mouseDown(int button, int left, int top);
boolean mouseOut(int button, int left, int top);
boolean mouseOver(int button, int left, int top);
boolean mouseUp(int button, int left, int top);
void waitForElement(int timeout, int interval);
void waitThenClick(int timeout, int interval);

CheckBox Method overview

boolean check(int left, int top);

RadioButton Method overview

boolean select(int left, int top);

DropList Method overview

boolean select(int left, int top);

TextBox Method overview

boolean sendKeys(int left, int top);

 

click()

Fires a normal (left) click at the given element. You can optionally pass in coordinates to the function for where to click. The coordinates are relative to the element's bounding rectangle. With no coordinates specified, it clicks as 0, 0 on that rectangle (top left corner).

boolean click(
  [in int left],
  [in int top]
);
Parameters
left
Left coordinate for click (optional, defaults to 0)
top
Top coordinate for click (optional, defaults to 0)
Return value

true if the action succeeds, otherwise false.

Example
var button = getElementBy.ID(controller.tabs.activeTab, 'buttonID');
button.click();
// Or specify coordinates
button.click(20, 10);

doubleClick()

Fires a normal (left) double click at the given element. You can optionally pass in coordinates to the function for where to click. The coordinates are relative to the element's bounding rectangle. With no coordinates specified, it clicks as 0, 0 on that rectangle (top left corner).

boolean doubleClick(
  [in int left],
  [in int top]
);
Parameters
left
Left coordinate for click (optional, defaults to 0)
top
Top coordinate for click (optional, defaults to 0)
Return value

true if the action succeeds, otherwise false.

Example
var element = findElement.ID(controller.tabs.activeTab, 'elementName');
element.doubleClick();
// Or specify coordinates
element.doubleClick(20, 10);

rightClick()

Fires a right click at the given element. You can optionally pass in coordinates to the function for where to click. The coordinates are relative to the element's bounding rectangle. With no coordinates specified, it clicks as 0, 0 on that rectangle (top left corner).

boolean rightClick(
  [in int left],
  [in int top]
); 
Parameters
left
Left coordinate for click (optional, defaults to 0)
top
Top coordinate for click (optional, defaults to 0)
Return value

true if the action succeeds, otherwise false.

Example
var element = findElement.ID(controller.window.document, 'elementID');
element.rightClick();
// Or specify coordinates
element.rightClick(20, 10);

keypress()

Sends a key event for the given keycode. The modifiers are a JSON object that specifies what key modifiers should be pressed in conjunction with the given key code. The available attribute names for the modifier object are: ctrlKey, altKey, shiftKey, metaKey, and accelKey. Try to avoid the usage of ctrlKey and metaKey if the shortcut is a combination of Ctrl (Windows/Linux) and Cmd (Mac) and use accelKey instead which will work regardless of which operating system your test is executing on.

boolean keypress(
  in string keycode,
  [in object modifiers]
); 
Parameters
keycode
The key code. Either a literal keycode like 'b' or an enum key code like 'VK_ESCAPE'
modifiers
Object of modifiers for this keypress.
Return value

true if the action succeeds, otherwise false.

Example
// Fire an escape key strokes at an element:
var element = findElement.ID(controller.window.document, 'elementID');
element.keypress('VK_ESCAPE');

// Fire a simple key stroke at an element using the control/command and shift keys
element.keypress('b', {shiftKey: true, accelKey: true});

mouseDown()

Simulates the left button being depressed on the mouse when the mouse is over the given element.

boolean mouseDown(
  in int button,
  [in int left],
  [in int top]
); 
Parameters
button
The id of the button to press (0 - left, 1 - middle, 2 - right)
left
The relative horizontal coordinate inside the target element to click
top
The relative vertical coordinate inside the target element to click
Return value

true if the action succeeds, otherwise false.

Example
var element = findElement.ID(controller.window.document, 'elementID');
element.mouseDown(1);  // middle button down

mouseOut()

Simulates the mouse leaving the area over an event without clicking on it. If the element is out of view, the element will be scrolled into view before initiating the mouseOut.

boolean mouseOut(
  [in int button],
  [in int left],
  [in int top]
); 
Parameters
button
The id of the button to press (0 - left, 1 - middle, 2 - right)
left
The relative horizontal coordinate inside the target element
top
The relative vertical coordinate inside the target element
Return value

true if the action succeeds, otherwise false.

Example
var element = findElement.ID(controller.window.document, 'elementID');
element.mouseOut();

mouseOver()

Simulates the mouse entering the area over an event without clicking on it. If the element is out of view, the element will be scrolled into view before initiating the mouseOver

boolean mouseOver(
  [in int button],
  [in int left],
  [in int top]
); 
Parameters
button
The id of the button to press (0 - left, 1 - middle, 2 - right)
left
The relative horizontal coordinate inside the target element
top
The relative vertical coordinate inside the target element
Return value

true if the action succeeds, otherwise false.

Example
var element = findElement(controller.window.document, 'elementID');
element.mouseOver();

mouseUp()

Simulates the a mouse button being released on the mouse when the mouse is over the given element.

boolean mouseUp(
  [in int button],
  [in int left],
  [in int top]
); 
Parameters
button
The id of the button to press (0 - left/default, 1 - middle, 2 - right)
left
The relative horizontal coordinate inside the target element
top
The relative vertical coordinate inside the target element
Return value

true if the action succeeds, otherwise false.

Example
var element = findElement.ID(controller.window.document, 'elementID');
element.mouseUp();

waitForElement()

Waits for the "element" to appear in the user interface (for instance if you wanted to wait for part of a page or dialog to load). It checks for "element" every "interval" milliseconds, and gives up if "timeout" milliseconds have passed without the "element" appearing, causing the test to fail. If you accept the defaults, it will check for the element every 100ms and will throw an error if 30 seconds pass without the element appearing.

void waitForElement(
  [in int timeout],
  [in int interval]
); 
Parameters
timeout
Total time in milliseconds to wait
interval
How often to check if the element has appeared
Return value

None

Example
// Typical usage - accept defaults.  See waitForEval() to see non-default operation
findElement.ID(controller.window.document, 'elementID').waitForElement();

waitThenClick()

Waits for the "element" to appear in the user interface. It checks for "element" every "interval" milliseconds, and gives up if "timeout" milliseconds have passed without the "element" appearing, causing the test to fail. Once "element" appears, a click event is immediately fired at it. This is a simple shortcut API for the common pattern of waiting for an element to appear before firing a click event on it.

void waitThenClick(
  [in int timeout],
  [in int interval]
); 
Parameters
timeout
Total time in milliseconds to wait
interval
How often to check if the element has appeared
Return value

None

Example
// Typical usage - accept defaults.  See waitForEval() to see non-default operation
findElement.ID(controller.window.document, 'elementID').waitThenClick();

check()

Fires a click at the given checkbox element to ensure it is either checked or not.

boolean check(
  in boolean state
); 
Parameters
state
Pass true to ensure the element is checked, false to ensure it is unchecked. Defaults to false
Return value

true if the action succeeds, otherwise false.

Example
var checkbox = findElement(controller.window.document, 'checkboxID');
checkbox.check(true);

select() - radio

Selects the given radio button by firing a click at it.

boolean radio(); 
Return value

true if the action succeeds, otherwise false.

Example
var radio = findElement(controller.window.document, 'radioID');
radio.select();

select() - textbox

Handles selecting an option from a menupopup or an HTML select element. The "element" corresponds to the list. There are multiple ways to select from such a list, either by "index", "label", or by the "value" associated with that option.

  • index - to use an index, give it a valid index >=0. If you do not wish to use an index, pass 'null' for this field. Using an index of -1 will reset the current selection.
  • label - to use label, supply the label. If you do not wish to use an option name, then pass 'null' in this field.
  • value - to use the value attribute, supply the valid value in this field. If you choose not to supply a value, you can simply leave it off when not including it or pass in 'null'.
boolean select(
  in int index,
  in string label,
  in string value
); 
Parameters
index
index of item in drop down list. Use null if you do not wish to specify an index. -1 will reset the selection.
label
Label of the option you wish to select, if you do not wish to use it pass null
value
Value of the option you wish to select, if you do not wish to use this field either leave it off or pass null
Return value

true if the action succeeds, otherwise false.

Example
// Select only using the index
var list = findElement(controller.window.document, 'listID');
list.select(2);

// Select using the label
list.select(null, 'listItemLabel');

sendKeys()

Types a string of text at the given element. The modifiers are a JSON object that specifies what key modifiers should be pressed in conjunction with the given key code. The available attribute names for the modifier object are: ctrlKey, altKey, shiftKey, metaKey, and accelKey. Try to avoid the usage of ctrlKey and metaKey if the shortcut is a combination of Ctrl (Windows/Linux) and Cmd (Mac) and use accelKey instead which will work regardless of which operating system your test is executing on.

boolean sendKeys(
  in string text,
  [in object modifiers]
);
Parameters
text
The text to type
modifiers
Object of modifiers for this keypress.
Return value

true if the action succeeds, otherwise false.

Example
var textbox = findElement.ID(controller.window.document, 'textboxID');
textbox.sendKeys('some text to type');

Revision Source

<p><strong>This page is currently under development and is only relevant to Mozmill 2.0 and later.</strong></p>
<p>When you manipulate DOM elements with Mozmill, you are actually using a wrapper object that wraps around the DOM element node. This wrapper object contains all the methods that are relevant to the actual DOM node. For example, if you obtain a 'button' element, you can expect to find a 'button.click()' method. If you have a 'menulist' element, you can expect a 'menulist.select()' method. Note that the 'select' method <em>will not</em> be available on, for example, a 'button' element.</p>
<p>The wrapper objects are set up as a hierarchy which can be extended and customized as you see fit (see <a href="/en/Mozmill/Mozmill_Element_Object/Extending_Element_Hierarchy" title="Extending the Mozmill Element Hierarchy">extending the mozmill element hierarchy</a>) . The base element contains all methods and properties that are common across all elements. Element types that have specific functionality sub-class this base class.</p>
<h2>Element Method overview</h2>
<p>All sub-classes of elements have these methods.</p>
<table class="standard-table"> <tbody> <tr> <td><code>boolean <a href="#click.28.29">click</a>(int left, int top);</code></td> </tr> <tr> <td><code>boolean <a href="#doubleClick.28.29">doubleClick</a>(int left, int top);</code></td> </tr> <tr> <td><code>boolean <a href="#rightClick.28.29">rightClick</a>(int left, int top);</code></td> </tr> <tr> <td><code>boolean <a href="#keypress.28.29">keypress</a>(string keycode, object modifiers);</code></td> </tr> <tr> <td><code>boolean <a href="#mouseDown.28.29">mouseDown</a>(int button, int left, int top);</code></td> </tr> <tr> <td><code>boolean <a href="#mouseOut.28.29">mouseOut</a>(int button, int left, int top</code><code>);</code></td> </tr> <tr> <td><code>boolean <a href="#mouseOver.28.29">mouseOver</a>(int button, int left, int top</code><code>);</code></td> </tr> <tr> <td><code>boolean <a href="#mouseUp.28.29">mouseUp</a>(int button, int left, int top</code><code>);</code></td> </tr> <tr> <td><code>void <a href="#waitForElement.28.29">waitForElement</a>(int timeout, int interval);</code></td> </tr> <tr> <td><code>void <a href="#waitThenClick.28.29">waitThenClick</a>(int timeout, int interval);</code></td> </tr> </tbody>
</table>
<h2>CheckBox Method overview</h2>
<table class="standard-table"> <tbody> <tr> <td><code>boolean <a href="#check.28.29">check</a>(int left, int top);</code></td> </tr> </tbody>
</table>
<h2>RadioButton Method overview</h2>
<table class="standard-table"> <tbody> <tr> <td><code>boolean <a href="#radioSelect.28.29">select</a>(int left, int top);</code></td> </tr> </tbody>
</table>
<h2>DropList Method overview</h2>
<table class="standard-table"> <tbody> <tr> <td><code>boolean <a href="#textboxSelect.28.29">select</a>(int left, int top);</code></td> </tr> </tbody>
</table>
<h2>TextBox Method overview</h2>
<table class="standard-table"> <tbody> <tr> <td><code>boolean <a href="#sendKeys.28.29">sendKeys</a>(int left, int top);</code></td> </tr> </tbody>
</table>
<p> </p>
<h3 name="click.28.29">click()</h3>
<p>Fires a normal (left) click at the given element. You can optionally pass in coordinates to the function for where to click. The coordinates are relative to the element's bounding rectangle. With no coordinates specified, it clicks as 0, 0 on that rectangle (top left corner).</p>
<pre>boolean click(
  [in int left],
  [in int top]
);
</pre>
<h6>Parameters</h6>
<dl> <dt><code>left</code></dt> <dd>Left coordinate for click (optional, defaults to 0)</dd> <dt><code>top</code></dt> <dd>Top coordinate for click (optional, defaults to 0)</dd>
</dl>
<h6>Return value</h6>
<p><code>true</code> if the action succeeds, otherwise <code>false</code>.</p>
<h6>Example</h6>
<pre class="deki-transform">var button = getElementBy.ID(controller.tabs.activeTab, 'buttonID');
button.click();
// Or specify coordinates
button.click(20, 10);
</pre>
<h3 name="doubleClick.28.29">doubleClick()</h3>
<p>Fires a normal (left) double click at the given element. You can optionally pass in coordinates to the function for where to click. The coordinates are relative to the element's bounding rectangle. With no coordinates specified, it clicks as 0, 0 on that rectangle (top left corner).</p>
<pre>boolean doubleClick(
  [in int left],
  [in int top]
);
</pre>
<h6>Parameters</h6>
<dl> <dt><code>left</code></dt> <dd>Left coordinate for click (optional, defaults to 0)</dd> <dt><code>top</code></dt> <dd>Top coordinate for click (optional, defaults to 0)</dd>
</dl>
<h6>Return value</h6>
<p><code>true</code> if the action succeeds, otherwise <code>false</code>.</p>
<h6>Example</h6>
<pre class="deki-transform">var element = findElement.ID(controller.tabs.activeTab, 'elementName');
element.doubleClick();
// Or specify coordinates
element.doubleClick(20, 10);
</pre>
<h3 name="rightClick.28.29">rightClick()</h3>
<p>Fires a right click at the given element. You can optionally pass in coordinates to the function for where to click. The coordinates are relative to the element's bounding rectangle. With no coordinates specified, it clicks as 0, 0 on that rectangle (top left corner).</p>
<pre>boolean rightClick(
  [in int left],
  [in int top]
); 
</pre>
<h6>Parameters</h6>
<dl> <dt><code>left</code></dt> <dd>Left coordinate for click (optional, defaults to 0)</dd> <dt><code>top</code></dt> <dd>Top coordinate for click (optional, defaults to 0)</dd>
</dl>
<h6>Return value</h6>
<p><code>true</code> if the action succeeds, otherwise <code>false</code>.</p>
<h6>Example</h6>
<pre class="deki-transform">var element = findElement.ID(controller.window.document, 'elementID');
element.rightClick();
// Or specify coordinates
element.rightClick(20, 10);
</pre>
<h3 name="keypress.28.29">keypress()</h3>
<p>Sends a key event for the given keycode. The modifiers are a JSON object that specifies what key modifiers should be pressed in conjunction with the given key code. The available attribute names for the modifier object are: ctrlKey, altKey, shiftKey, metaKey, and accelKey. Try to avoid the usage of ctrlKey and metaKey if the shortcut is a combination of Ctrl (Windows/Linux) and Cmd (Mac) and use accelKey instead which will work regardless of which operating system your test is executing on.</p>
<pre>boolean keypress(
  in string keycode,
  [in object modifiers]
); 
</pre>
<h6>Parameters</h6>
<dl> <dt><code>keycode</code></dt> <dd>The key code. Either a literal keycode like 'b' or an <a href="/en/XUL_Tutorial/Keyboard_Shortcuts" title="en/XUL_Tutorial/Keyboard_Shortcuts">enum key code</a> like 'VK_ESCAPE'</dd> <dt><code>modifiers</code></dt> <dd>Object of modifiers for this keypress.</dd>
</dl>
<h6>Return value</h6>
<p><code>true</code> if the action succeeds, otherwise <code>false</code>.</p>
<h6>Example</h6>
<pre class="deki-transform">// Fire an escape key strokes at an element:
var element = findElement.ID(controller.window.document, 'elementID');
element.keypress('VK_ESCAPE');

// Fire a simple key stroke at an element using the control/command and shift keys
element.keypress('b', {shiftKey: true, accelKey: true});
</pre>
<h3 name="mouseDown.28.29">mouseDown()</h3>
<p>Simulates the left button being depressed on the mouse when the mouse is over the given element.</p>
<pre>boolean mouseDown(
  in int button,
  [in int left],
  [in int top]
); 
</pre>
<h6>Parameters</h6>
<dl> <dt><code>button</code></dt> <dd>The id of the button to press (0 - left, 1 - middle, 2 - right)</dd> <dt><code>left</code></dt> <dd>The relative horizontal coordinate inside the target element to click</dd> <dt><code>top</code></dt> <dd>The relative vertical coordinate inside the target element to click</dd>
</dl>
<h6>Return value</h6>
<p><code>true</code> if the action succeeds, otherwise <code>false</code>.</p>
<h6>Example</h6>
<pre class="deki-transform">var element = findElement.ID(controller.window.document, 'elementID');
element.mouseDown(1);  // middle button down
</pre>
<h3 name="mouseOut.28.29">mouseOut()</h3>
<p>Simulates the mouse leaving the area over an event without clicking on it. If the element is out of view, the element will be scrolled into view before initiating the mouseOut.</p>
<pre>boolean mouseOut(
  [in int button],
  [in int left],
  [in int top]
); 
</pre>
<h6>Parameters</h6>
<dl> <dt><code>button</code></dt> <dd>The id of the button to press (0 - left, 1 - middle, 2 - right)</dd> <dt><code>left</code></dt> <dd>The relative horizontal coordinate inside the target element</dd> <dt><code>top</code></dt> <dd>The relative vertical coordinate inside the target element</dd>
</dl>
<h6>Return value</h6>
<p><code>true</code> if the action succeeds, otherwise <code>false</code>.</p>
<h6>Example</h6>
<pre class="deki-transform">var element = findElement.ID(controller.window.document, 'elementID');
element.mouseOut();
</pre>
<h3 name="mouseOver.28.29">mouseOver()</h3>
<p>Simulates the mouse entering the area over an event without clicking on it. If the element is out of view, the element will be scrolled into view before initiating the mouseOver</p>
<pre>boolean mouseOver(
  [in int button],
  [in int left],
  [in int top]
); 
</pre>
<h6>Parameters</h6>
<dl> <dt><code>button</code></dt> <dd>The id of the button to press (0 - left, 1 - middle, 2 - right)</dd> <dt><code>left</code></dt> <dd>The relative horizontal coordinate inside the target element</dd> <dt><code>top</code></dt> <dd>The relative vertical coordinate inside the target element</dd>
</dl>
<h6>Return value</h6>
<p><code>true</code> if the action succeeds, otherwise <code>false</code>.</p>
<h6>Example</h6>
<pre class="deki-transform">var element = findElement(controller.window.document, 'elementID');
element.mouseOver();
</pre>
<h3 name="mouseUp.28.29">mouseUp()</h3>
<p>Simulates the a mouse button being released on the mouse when the mouse is over the given element.</p>
<pre>boolean mouseUp(
  [in int button],
  [in int left],
  [in int top]
); 
</pre>
<h6>Parameters</h6>
<dl> <dt><code>button</code></dt> <dd>The id of the button to press (0 - left/default, 1 - middle, 2 - right)</dd> <dt><code>left</code></dt> <dd>The relative horizontal coordinate inside the target element</dd> <dt><code>top</code></dt> <dd>The relative vertical coordinate inside the target element</dd>
</dl>
<h6>Return value</h6>
<p><code>true</code> if the action succeeds, otherwise <code>false</code>.</p>
<h6>Example</h6>
<pre class="deki-transform">var element = findElement.ID(controller.window.document, 'elementID');
element.mouseUp();
</pre>
<h3 name="waitForElement.28.29">waitForElement()</h3>
<p>Waits for the "element" to appear in the user interface (for instance if you wanted to wait for part of a page or dialog to load). It checks for "element" every "interval" milliseconds, and gives up if "timeout" milliseconds have passed without the "element" appearing, causing the test to fail. If you accept the defaults, it will check for the element every 100ms and will throw an error if 30 seconds pass without the element appearing.</p>
<pre>void waitForElement(
  [in int timeout],
  [in int interval]
); 
</pre>
<h6>Parameters</h6>
<dl> <dt><code>timeout</code></dt> <dd>Total time in milliseconds to wait</dd> <dt><code>interval</code></dt> <dd>How often to check if the element has appeared</dd>
</dl>
<h6>Return value</h6>
<p>None</p>
<h6>Example</h6>
<pre class="deki-transform">// Typical usage - accept defaults.  See waitForEval() to see non-default operation
findElement.ID(controller.window.document, 'elementID').waitForElement();
</pre>
<h3 name="waitThenClick.28.29">waitThenClick()</h3>
<p>Waits for the "element" to appear in the user interface. It checks for "element" every "interval" milliseconds, and gives up if "timeout" milliseconds have passed without the "element" appearing, causing the test to fail. Once "element" appears, a click event is immediately fired at it. This is a simple shortcut API for the common pattern of waiting for an element to appear before firing a click event on it.</p>
<pre>void waitThenClick(
  [in int timeout],
  [in int interval]
); 
</pre>
<h6>Parameters</h6>
<dl> <dt><code>timeout</code></dt> <dd>Total time in milliseconds to wait</dd> <dt><code>interval</code></dt> <dd>How often to check if the element has appeared</dd>
</dl>
<h6>Return value</h6>
<p>None</p>
<h6>Example</h6>
<pre class="deki-transform">// Typical usage - accept defaults.  See waitForEval() to see non-default operation
findElement.ID(controller.window.document, 'elementID').waitThenClick();
</pre>
<h3 name="check.28.29">check()</h3>
<p>Fires a click at the given checkbox element to ensure it is either checked or not.</p>
<pre>boolean check(
  in boolean state
); 
</pre>
<h6>Parameters</h6>
<dl> <dt><code>state</code></dt> <dd>Pass true to ensure the element is checked, false to ensure it is unchecked. Defaults to false</dd>
</dl>
<h6>Return value</h6>
<p><code>true</code> if the action succeeds, otherwise <code>false</code>.</p>
<h6>Example</h6>
<pre class="brush: js">var checkbox = findElement(controller.window.document, 'checkboxID');
checkbox.check(true);
</pre>
<h3 name="radioSelect.28.29">select() - radio</h3>
<p>Selects the given radio button by firing a click at it.</p>
<pre>boolean radio(); 
</pre>
<h6>Return value</h6>
<p><code>true</code> if the action succeeds, otherwise <code>false</code>.</p>
<h6>Example</h6>
<pre class="brush: js">var radio = findElement(controller.window.document, 'radioID');
radio.select();
</pre>
<h3 name="textboxSelect.28.29">select() - textbox</h3>
<p>Handles selecting an option from a menupopup or an HTML select element. The "element" corresponds to the list. There are multiple ways to select from such a list, either by "index", "label", or by the "value" associated with that option.</p>
<ul> <li>index - to use an index, give it a valid index &gt;=0. If you do not wish to use an index, pass 'null' for this field. Using an index of -1 will reset the current selection.</li> <li>label - to use label, supply the label. If you do not wish to use an option name, then pass 'null' in this field.</li> <li>value - to use the value attribute, supply the valid value in this field. If you choose not to supply a value, you can simply leave it off when not including it or pass in 'null'.</li>
</ul>
<pre>boolean select(
  in int index,
  in string label,
  in string value
); 
</pre>
<h6>Parameters</h6>
<dl> <dt><code>index</code></dt> <dd>index of item in drop down list. Use <code>null</code> if you do not wish to specify an index. -1 will reset the selection.</dd> <dt><code>label</code></dt> <dd>Label of the option you wish to select, if you do not wish to use it pass <code>null</code></dd> <dt><code>value</code></dt> <dd>Value of the option you wish to select, if you do not wish to use this field either leave it off or pass <code>null</code></dd>
</dl>
<h6>Return value</h6>
<p><code>true</code> if the action succeeds, otherwise <code>false</code>.</p>
<h6>Example</h6>
<pre class="brush: js">// Select only using the index
var list = findElement(controller.window.document, 'listID');
list.select(2);

// Select using the label
list.select(null, 'listItemLabel');
</pre>
<h3 name="sendKeys.28.29">sendKeys()</h3>
<p>Types a string of text at the given element. The modifiers are a JSON object that specifies what key modifiers should be pressed in conjunction with the given key code. The available attribute names for the modifier object are: ctrlKey, altKey, shiftKey, metaKey, and accelKey. Try to avoid the usage of ctrlKey and metaKey if the shortcut is a combination of Ctrl (Windows/Linux) and Cmd (Mac) and use accelKey instead which will work regardless of which operating system your test is executing on.</p>
<pre>boolean sendKeys(
  in string text,
  [in object modifiers]
);
</pre>
<h6>Parameters</h6>
<dl> <dt><code>text</code></dt> <dd>The text to type</dd> <dt><code>modifiers</code></dt> <dd>Object of modifiers for this keypress.</dd>
</dl>
<h6>Return value</h6>
<p><code>true</code> if the action succeeds, otherwise <code>false</code>.</p>
<h6>Example</h6>
<pre class="deki-transform">var textbox = findElement.ID(controller.window.document, 'textboxID');
textbox.sendKeys('some text to type');
</pre>
Revert to this revision