leadfoot/Command
Inheritance
- leadfoot/Command
- Object
new (require("leadfoot/Command"))(parent: leadfoot/Command|leadfoot/Session, initialiser: function, errbackopt: function)
The Command class is a chainable, subclassable object type that can be used to execute commands serially against a remote WebDriver environment. The standard Command class includes methods from the leadfoot/Session and leadfoot/Element classes, so you can perform all standard session and element operations that come with Leadfoot without being forced to author long promise chains.
Important: Due to a documentation tool limitation, the documentation on this page currently lists return values
of all methods as being of type Promise. All command methods actually return a new object of type Command. This
issue will be addressed in future versions of the documentation.
In order to use the Command class, you first need to pass it a leadfoot/Session instance for it to use:
var command = new Command(session);Once you have created the Command, you can then start chaining methods, and they will execute in order one after another:
command.get('http://example.com')
.findByTagName('h1')
.getVisibleText()
.then(function (text) {
assert.strictEqual(text, 'Example Domain');
});Because these operations are asynchronous, you need to use a then callback in order to retrieve the value from the
last method. Command objects are Thenables, which means that they can be used with any Promises/A+ or ES6-confirmant
Promises implementation, though there are some specific differences in the arguments and context that are provided
to callbacks; see leadfoot/Command#then for more details.
Each call on a Command generates a new Command object, which means that certain operations can be parallelised:
command = command.get('http://example.com');
Promise.all([
command.getPageTitle(),
command.findByTagName('h1').getVisibleText()
]).then(function (results) {
assert.strictEqual(results[0], results[1]);
});In this example, the commands on line 3 and 4 both depend upon the get call completing successfully but are
otherwise independent of each other and so execute here in parallel. This is different from commands in Intern 1
which were always chained onto the last called method within a given test.
Command objects actually encapsulate two different types of interaction: session interactions, which operate against the entire browser session, and element interactions, which operate against specific elements taken from the currently loaded page. Things like navigating the browser, moving the mouse cursor, and executing scripts are session interactions; things like getting text displayed on the page, typing into form fields, and getting element attributes are element interactions.
Session interactions can be performed at any time, from any Command. On the other hand, to perform element
interactions, you first need to retrieve one or more elements to interact with. This can be done using any of the
find or findAll methods, by the getActiveElement method, or by returning elements from execute or
executeAsync calls. The retrieved elements are stored internally as the element context of all chained
Commands. When an element method is called on a chained Command with a single element context, the result will be
returned as-is:
command = command.get('http://example.com')
// finds one element -> single element context
.findByTagName('h1')
.getVisibleText()
.then(function (text) {
// `text` is the text from the element context
assert.strictEqual(text, 'Example Domain');
});When an element method is called on a chained Command with a multiple element context, the result will be returned as an array:
command = command.get('http://example.com')
// finds multiple elements -> multiple element context
.findAllByTagName('p')
.getVisibleText()
.then(function (texts) {
// `texts` is an array of text from each of the `p` elements
assert.deepEqual(texts, [
'This domain is established to be used for […]',
'More information...'
]);
});The find and findAll methods are special and change their behaviour based on the current element filtering state
of a given command. If a command has been filtered by element, the find and findAll commands will only find
elements within the currently filtered set of elements. Otherwise, they will find elements throughout the page.
Some method names, like click, are identical for both Session and Element APIs; in this case, the element APIs
are suffixed with the word Element in order to identify them uniquely.
Commands can be subclassed in order to add additional functionality without making direct modifications to the default Command prototype that might break other parts of the system:
function CustomCommand() {
Command.apply(this, arguments);
}
CustomCommand.prototype = Object.create(Command.prototype);
CustomCommand.prototype.constructor = CustomCommand;
CustomCommand.prototype.login = function (username, password) {
return new this.constructor(this, function () {
return this.parent
.findById('username')
.click()
.type(username)
.end()
.findById('password')
.click()
.type(password)
.end()
.findById('login')
.click()
.end();
});
};Note that returning this, or a command chain starting from this, from a callback or command initialiser will
deadlock the Command, as it waits for itself to settle before settling.
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
parent |
leadfoot/Command|leadfoot/Session |
The parent command that this command is chained to, or a leadfoot/Session object if this is the first command in a command chain. |
|
initialiser |
function |
A function that will be executed when all parent commands have completed execution. This function can create a
new context for this command by calling the passed |
|
errback |
function | optional |
A function that will be executed if any parent commands failed to complete successfully. This function can create
a new context for the current command by calling the passed |
Source
All Properties
| Property | Defined by |
|---|---|
|
context: Array.<leadfoot/Element>
(readonly)
The filtered elements that will be used if an element-specific method is invoked. |
leadfoot/Command |
|
(readonly)
The parent Command of the Command, if one exists. |
leadfoot/Command |
|
promise: Promise.<any>
(readonly)
The underlying Promise for the Command. |
leadfoot/Command |
|
(readonly)
The parent Session of the Command. |
leadfoot/Command |
All Methods
| Method | Defined by |
|---|---|
|
Command.addElementMethod(target: leadfoot/Command, key: string)
(static)
Augments |
leadfoot/Command |
|
Command.addSessionMethod(target: leadfoot/Command, key: string, originalFn: function)
(static)
Augments |
leadfoot/Command |
|
Accepts an alert, prompt, or confirmation pop-up. |
leadfoot/Command |
|
Activates an input method editor in the remote environment. |
leadfoot/Command |
|
Cancels all outstanding chained operations of the Command. |
leadfoot/Command |
|
Adds a callback to be invoked when any of the previously chained operations have failed. |
leadfoot/Command |
|
Clears all cookies for the current page. |
leadfoot/Command |
|
Clears all data in local storage for the focused window/frame. |
leadfoot/Command |
|
Clears all data in session storage for the focused window/frame. |
leadfoot/Command |
|
Clears the value of a form element. |
leadfoot/Command |
|
Clicks the element. |
leadfoot/Command |
|
Clicks a mouse button at the point where the mouse cursor is currently positioned. |
leadfoot/Command |
|
Closes the currently focused window. |
leadfoot/Command |
|
Deactivates any active input method editor in the remote environment. |
leadfoot/Command |
|
Deletes a cookie on the current page. |
leadfoot/Command |
|
Deletes a value from local storage for the focused window/frame. |
leadfoot/Command |
|
Deletes a value from session storage for the focused window/frame. |
leadfoot/Command |
|
Dismisses an alert, prompt, or confirmation pop-up. |
leadfoot/Command |
|
Double-clicks the primary mouse button. |
leadfoot/Command |
|
Performs a double-tap gesture on an element. |
leadfoot/Command |
|
Ends the most recent filtering operation in the current Command chain and returns the set of matched elements to the previous state. |
leadfoot/Command |
|
Determines if this element is equal to another element. |
leadfoot/Command |
|
Executes JavaScript code within the focused window/frame. |
leadfoot/Command |
|
Executes JavaScript code within the focused window/frame. |
leadfoot/Command |
|
Adds a callback to be invoked once the previously chained operations have resolved. |
leadfoot/Command |
|
Gets the first element from the focused window/frame that matches the given query. |
leadfoot/Command |
|
Gets an array of elements from the focused window/frame that match the given query. |
leadfoot/Command |
|
Gets all elements in the currently active window/frame matching the given CSS class name. |
leadfoot/Command |
|
Gets all elements in the currently active window/frame matching the given CSS selector. |
leadfoot/Command |
|
Gets all elements in the currently active window/frame matching the given case-insensitive link text. |
leadfoot/Command |
|
Gets all elements in the currently active window/frame matching the given name attribute. |
leadfoot/Command |
|
Gets all elements in the currently active window/frame partially matching the given case-insensitive link text. |
leadfoot/Command |
|
Gets all elements in the currently active window/frame matching the given HTML tag name. |
leadfoot/Command |
|
Gets all elements in the currently active window/frame matching the given XPath selector. |
leadfoot/Command |
|
Gets the first element in the currently active window/frame matching the given CSS class name. |
leadfoot/Command |
|
Gets the first element in the currently active window/frame matching the given CSS selector. |
leadfoot/Command |
|
Gets the first element in the currently active window/frame matching the given ID. |
leadfoot/Command |
|
Gets the first element in the currently active window/frame matching the given case-insensitive link text. |
leadfoot/Command |
|
Gets the first element in the currently active window/frame matching the given name attribute. |
leadfoot/Command |
|
Gets the first element in the currently active window/frame partially matching the given case-insensitive link text. |
leadfoot/Command |
|
Gets the first element in the currently active window/frame matching the given HTML tag name. |
leadfoot/Command |
|
Gets the first element in the currently active window/frame matching the given XPath selector. |
leadfoot/Command |
|
Gets the first displayed element in the currently active window/frame matching the given query. |
leadfoot/Command |
|
Gets the first displayed element in the currently active window/frame matching the given CSS class name. |
leadfoot/Command |
|
Gets the first displayed element in the currently active window/frame matching the given CSS selector. |
leadfoot/Command |
|
Gets the first displayed element in the currently active window/frame matching the given ID. |
leadfoot/Command |
|
Gets the first displayed element in the currently active window/frame matching the given case-insensitive link text. |
leadfoot/Command |
|
Gets the first displayed element in the currently active window/frame matching the given name attribute. |
leadfoot/Command |
|
Gets the first displayed element in the currently active window/frame partially matching the given case-insensitive link text. |
leadfoot/Command |
|
Gets the first displayed element in the currently active window/frame matching the given HTML tag name. |
leadfoot/Command |
|
Gets the first displayed element in the currently active window/frame matching the given XPath selector. |
leadfoot/Command |
|
flickFinger(element: leadfoot/Element, xOffset: number, yOffset: number, speed: number): Promise.<void>
Flicks a finger. |
leadfoot/Command |
|
Navigates the focused window/frame to a new URL. |
leadfoot/Command |
|
Gets the currently focused element from the focused window/frame. |
leadfoot/Command |
|
Gets the currently active input method editor for the remote environment. |
leadfoot/Command |
|
Gets the text displayed in the currently active alert pop-up. |
leadfoot/Command |
|
Gets a list of identifiers for all currently open windows. |
leadfoot/Command |
|
Gets the current state of the HTML5 application cache for the current page. |
leadfoot/Command |
|
Gets an attribute of the element. |
leadfoot/Command |
|
Gets a list of input method editor engines available to the remote environment. |
leadfoot/Command |
|
Gets the types of logs that are currently available for retrieval from the remote environment. |
leadfoot/Command |
|
Gets a CSS computed property value for the element. |
leadfoot/Command |
|
Gets all cookies set on the current page. |
leadfoot/Command |
|
Gets the URL that is loaded in the focused window/frame. |
leadfoot/Command |
|
Gets the identifier for the window that is currently focused. |
leadfoot/Command |
|
Gets the timeout for leadfoot/Session#executeAsync calls. |
leadfoot/Command |
|
Gets the timeout for leadfoot/Session#find calls. |
leadfoot/Command |
|
Gets the current geographical location of the remote environment. |
leadfoot/Command |
|
Gets a value from local storage for the focused window/frame. |
leadfoot/Command |
|
Gets the list of keys set in local storage for the focused window/frame. |
leadfoot/Command |
|
Gets the number of keys set in local storage for the focused window/frame. |
leadfoot/Command |
|
Gets all logs from the remote environment of the given type. |
leadfoot/Command |
|
Gets the current screen orientation. |
leadfoot/Command |
|
Gets the timeout for leadfoot/Session#get calls. |
leadfoot/Command |
|
Gets the HTML loaded in the focused window/frame. |
leadfoot/Command |
|
Gets the title of the top-level browsing context of the current window or tab. |
leadfoot/Command |
|
Gets the position of the element relative to the top-left corner of the document, taking into account scrolling and CSS transformations (if they are supported). |
leadfoot/Command |
|
Gets a property of the element. |
leadfoot/Command |
|
Gets a value from session storage for the focused window/frame. |
leadfoot/Command |
|
Gets the list of keys set in session storage for the focused window/frame. |
leadfoot/Command |
|
Gets the number of keys set in session storage for the focused window/frame. |
leadfoot/Command |
|
Gets the size of the element, taking into account CSS transformations (if they are supported). |
leadfoot/Command |
|
Gets a property or attribute of the element according to the WebDriver specification algorithm. |
leadfoot/Command |
|
Gets the tag name of the element. |
leadfoot/Command |
|
Gets the current value of a timeout for the session. |
leadfoot/Command |
|
Gets the visible text within the element. |
leadfoot/Command |
|
Gets the position of a window. |
leadfoot/Command |
|
Gets the dimensions of a window. |
leadfoot/Command |
|
Navigates the focused window/frame back one page using the browser’s navigation history. |
leadfoot/Command |
|
Navigates the focused window/frame forward one page using the browser’s navigation history. |
leadfoot/Command |
|
Returns whether or not the element would be visible to an actual user. |
leadfoot/Command |
|
Returns whether or not a form element can be interacted with. |
leadfoot/Command |
|
Returns whether or not an input method editor is currently active in the remote environment. |
leadfoot/Command |
|
Returns whether or not a form element is currently selected (for drop-down options and radio buttons), or whether or not the element is currently checked (for checkboxes). |
leadfoot/Command |
|
Performs a long-tap gesture on an element. |
leadfoot/Command |
|
Maximises a window according to the platform’s window system behaviour. |
leadfoot/Command |
|
Moves the last depressed finger to a new point on the touch screen. |
leadfoot/Command |
|
Moves the remote environment’s mouse cursor to the specified element or relative position. |
leadfoot/Command |
|
Depresses a new finger at the given point on a touch screen device without releasing it. |
leadfoot/Command |
|
Types into the focused window/frame/element. |
leadfoot/Command |
|
Depresses a mouse button without releasing it. |
leadfoot/Command |
|
Terminates the session. |
leadfoot/Command |
|
Reloads the current browser window/frame. |
leadfoot/Command |
|
Releases whatever finger exists at the given point on a touch screen device. |
leadfoot/Command |
|
Releases a previously depressed mouse button. |
leadfoot/Command |
|
Sets a cookie on the current page. |
leadfoot/Command |
|
Sets the timeout for leadfoot/Session#executeAsync calls. |
leadfoot/Command |
|
Sets the timeout for leadfoot/Session#find calls. |
leadfoot/Command |
|
Sets the geographical location of the remote environment. |
leadfoot/Command |
|
Sets a value in local storage for the focused window/frame. |
leadfoot/Command |
|
Sets the screen orientation. |
leadfoot/Command |
|
Sets the timeout for leadfoot/Session#get calls. |
leadfoot/Command |
|
Sets a value in session storage for the focused window/frame. |
leadfoot/Command |
|
Sets the value of a timeout for the session. |
leadfoot/Command |
|
Sets the position of a window. |
leadfoot/Command |
|
Sets the dimensions of a window. |
leadfoot/Command |
|
Pauses execution of the next command in the chain for |
leadfoot/Command |
|
Submits the element, if it is a form, or the form belonging to the element, if it is a form element. |
leadfoot/Command |
|
Switches the currently focused frame to a new frame. |
leadfoot/Command |
|
Switches the currently focused frame to the parent of the currently focused frame. |
leadfoot/Command |
|
Switches the currently focused window to a new window. |
leadfoot/Command |
|
Gets a screenshot of the focused window and returns it in PNG format. |
leadfoot/Command |
|
Taps an element on a touch screen device. |
leadfoot/Command |
|
Adds a callback to be invoked once the previously chained operation has completed. |
leadfoot/Command |
|
Scrolls the currently focused window on a touch screen device. |
leadfoot/Command |
|
Types into the element. |
leadfoot/Command |
|
Types into the currently active prompt pop-up. |
leadfoot/Command |
|
Waits for all elements in the currently active window/frame matching the given CSS class name to be destroyed. |
leadfoot/Command |
|
Waits for all elements in the currently active window/frame matching the given CSS selector to be destroyed. |
leadfoot/Command |
|
Waits for all elements in the currently active window/frame matching the given ID to be destroyed. |
leadfoot/Command |
|
Waits for all elements in the currently active window/frame matching the given case-insensitive link text to be destroyed. |
leadfoot/Command |
|
Waits for all elements in the currently active window/frame matching the given name attribute to be destroyed. |
leadfoot/Command |
|
Waits for all elements in the currently active window/frame partially matching the given case-insensitive link text to be destroyed. |
leadfoot/Command |
|
Waits for all elements in the currently active window/frame matching the given HTML tag name to be destroyed. |
leadfoot/Command |
|
Waits for all elements in the currently active window/frame matching the given XPath selector to be destroyed. |
leadfoot/Command |
Properties
(readonly) context: Array.<leadfoot/Element>
The filtered elements that will be used if an element-specific method is invoked. Note that this property is not valid until the parent Command has been settled. The context array also has two additional properties:
- isSingle (boolean): If true, the context will always contain a single element. This is used to differentiate
between methods that should still return scalar values (
find) and methods that should return arrays of values even if there is only one element in the context (findAll). - depth (number): The depth of the context within the command chain. This is used to prevent traversal into higher filtering levels by leadfoot/Command#end.
Source
(readonly) parent: leadfoot/Command
(readonly) promise: Promise.<any>
(readonly) session: leadfoot/Session
Methods
(static) Command.addElementMethod(target: leadfoot/Command, key: string)
Augments target with a method that will call key on all context elements stored within target.
This can be used to easily add new methods from any custom object that implements the Element API to any target
object that implements the Command API.
Functions that are copied may have the following extra properties in order to change the way that Command works with these functions:
createsContext(boolean): If this property is specified, the return value from the function will be used as the new context for the returned Command.
Parameters
| Name | Type |
|---|---|
target |
leadfoot/Command |
key |
string |
Source
(static) Command.addSessionMethod(target: leadfoot/Command, key: string, originalFn: function)
Augments target with a conversion of the originalFn method that enables its use with a Command object.
This can be used to easily add new methods from any custom object that implements the Session API to any target
object that implements the Command API.
Functions that are copied may have the following extra properties in order to change the way that Command works with these functions:
createsContext(boolean): If this property is specified, the return value from the function will be used as the new context for the returned Command.usesElement(boolean): If this property is specified, element(s) from the current context will be used as the first argument to the function, if the explicitly specified first argument is not already an element.
Parameters
| Name | Type |
|---|---|
target |
leadfoot/Command |
key |
string |
originalFn |
function |
Source
acceptAlert(): Promise.<void>
Accepts an alert, prompt, or confirmation pop-up. Equivalent to clicking the 'OK' button.
Source
activateIme(engine: string): Promise.<void>
Activates an input method editor in the remote environment. As of April 2014, no known remote environments support IME functions.
Parameters
| Name | Type | Description |
|---|---|---|
engine |
string |
The type of IME to activate. |
Source
cancel(): leadfoot/Command.<void>
Cancels all outstanding chained operations of the Command. Calling this method will cause this command and all subsequent chained commands to fail with a CancelError.
Source
catch(errback: function): leadfoot/Command.<any>
Adds a callback to be invoked when any of the previously chained operations have failed.
Parameters
| Name | Type |
|---|---|
errback |
function |
Source
clearCookies(): Promise.<void>
clearLocalStorage(): Promise.<void>
clearSessionStorage(): Promise.<void>
clearValue(): Promise.<void>
click(): Promise.<void>
Clicks the element. This method works on both mouse and touch platforms.
Source
clickMouseButton(buttonopt: number): Promise.<void>
Clicks a mouse button at the point where the mouse cursor is currently positioned. This method may fail to execute with an error if the mouse has not been moved anywhere since the page was loaded.
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
button |
number | optional |
The button to click. 0 corresponds to the primary mouse button, 1 to the middle mouse button, 2 to the secondary mouse button. Numbers above 2 correspond to any additional buttons a mouse might provide. |
Source
closeCurrentWindow(): Promise.<void>
Closes the currently focused window. In most environments, after the window has been closed, it is necessary to explicitly switch to whatever window is now focused.
Source
deactivateIme(): Promise.<void>
Deactivates any active input method editor in the remote environment. As of April 2014, no known remote environments support IME functions.
Source
deleteCookie(name: string): Promise.<void>
Deletes a cookie on the current page.
Parameters
| Name | Type | Description |
|---|---|---|
name |
string |
The name of the cookie to delete. |
Source
deleteLocalStorageItem(key: string): Promise.<void>
Deletes a value from local storage for the focused window/frame.
Parameters
| Name | Type | Description |
|---|---|---|
key |
string |
The key of the data to delete. |
Source
deleteSessionStorageItem(key: string): Promise.<void>
Deletes a value from session storage for the focused window/frame.
Parameters
| Name | Type | Description |
|---|---|---|
key |
string |
The key of the data to delete. |
Source
dismissAlert(): Promise.<void>
Dismisses an alert, prompt, or confirmation pop-up. Equivalent to clicking the 'OK' button of an alert pop-up or the 'Cancel' button of a prompt or confirmation pop-up.
Source
doubleClick(): Promise.<void>
doubleTap(element: leadfoot/Element): Promise.<void>
Performs a double-tap gesture on an element.
Parameters
| Name | Type | Description |
|---|---|---|
element |
leadfoot/Element |
The element to double-tap. |
Source
end(numCommandsToPopopt: number): leadfoot/Command.<void>
Ends the most recent filtering operation in the current Command chain and returns the set of matched elements
to the previous state. This is equivalent to the jQuery#end method.
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
numCommandsToPop |
number | optional |
The number of element contexts to pop. Defaults to 1. |
Example
command
.findById('parent') // sets filter to #parent
.findByClassName('child') // sets filter to all .child inside #parent
.getVisibleText()
.then(function (visibleTexts) {
// all the visible texts from the children
})
.end() // resets filter to #parent
.end(); // resets filter to nothing (the whole document)
Source
equals(other: leadfoot/Element): Promise.<boolean>
Determines if this element is equal to another element.
Parameters
| Name | Type |
|---|---|
other |
leadfoot/Element |
Source
execute(script: function|string, args: Array.<any>): Promise.<any>
Executes JavaScript code within the focused window/frame. The code should return a value synchronously.
Parameters
| Name | Type | Description |
|---|---|---|
script |
function|string |
The code to execute. This function will always be converted to a string, sent to the remote environment, and
reassembled as a new anonymous function on the remote end. This means that you cannot access any variables
through closure. If your code needs to get data from variables on the local end, they should be passed using
|
args |
Array.<any> |
An array of arguments that will be passed to the executed code. Only values that can be serialised to JSON, plus leadfoot/Element objects, can be specified as arguments. |
Returns
The value returned by the remote code. Only values that can be serialised to JSON, plus DOM elements, can be returned.
See
- leadfoot/Session#executeAsync to execute code that returns values asynchronously.
Source
executeAsync(script: function|string, args: Array.<any>): Promise.<any>
Executes JavaScript code within the focused window/frame. The code must invoke the provided callback in order to signal that it has completed execution.
Parameters
| Name | Type | Description |
|---|---|---|
script |
function|string |
The code to execute. This function will always be converted to a string, sent to the remote environment, and
reassembled as a new anonymous function on the remote end. This means that you cannot access any variables
through closure. If your code needs to get data from variables on the local end, they should be passed using
|
args |
Array.<any> |
An array of arguments that will be passed to the executed code. Only values that can be serialised to JSON, plus
leadfoot/Element objects, can be specified as arguments. In addition to these arguments, a
callback function will always be passed as the final argument to the function specified in |
Returns
The value returned by the remote code. Only values that can be serialised to JSON, plus DOM elements, can be returned.
See
- leadfoot/Session#execute to execute code that returns values synchronously.
- leadfoot/Session#setExecuteAsyncTimeout to set the time until an asynchronous script is considered timed out.
Source
finally(callback: function): leadfoot/Command.<any>
Adds a callback to be invoked once the previously chained operations have resolved.
Parameters
| Name | Type |
|---|---|
callback |
function |
Source
find(using: string, value: string): Promise.<leadfoot/Element>
Gets the first element from the focused window/frame that matches the given query.
Parameters
| Name | Type | Description |
|---|---|---|
using |
string |
The element retrieval strategy to use. One of 'class name', 'css selector', 'id', 'name', 'link text', 'partial link text', 'tag name', 'xpath'. |
value |
string |
The strategy-specific value to search for. For example, if |
See
- leadfoot/Session#setFindTimeout to set the amount of time it the remote environment should spend waiting for an element that does not exist at the time of the `find` call before timing out.
Source
findAll(using: string, value: string): Promise.<Array.<leadfoot/Element>>
Gets an array of elements from the focused window/frame that match the given query.
Parameters
| Name | Type | Description |
|---|---|---|
using |
string |
The element retrieval strategy to use. See leadfoot/Session#find for options. |
value |
string |
The strategy-specific value to search for. See leadfoot/Session#find for details. |
Source
findAllByClassName(className: string): Promise.<Array.<leadfoot/Element>>
Gets all elements in the currently active window/frame matching the given CSS class name.
Parameters
| Name | Type | Description |
|---|---|---|
className |
string |
The CSS class name to search for. |
Source
findAllByCssSelector(selector: string): Promise.<Array.<leadfoot/Element>>
Gets all elements in the currently active window/frame matching the given CSS selector.
Parameters
| Name | Type | Description |
|---|---|---|
selector |
string |
The CSS selector to search for. |
Source
findAllByLinkText(text: string): Promise.<Array.<leadfoot/Element>>
Gets all elements in the currently active window/frame matching the given case-insensitive link text.
Parameters
| Name | Type | Description |
|---|---|---|
text |
string |
The link text of the element. |
Source
findAllByName(name: string): Promise.<Array.<leadfoot/Element>>
Gets all elements in the currently active window/frame matching the given name attribute.
Parameters
| Name | Type | Description |
|---|---|---|
name |
string |
The name of the element. |
Source
findAllByPartialLinkText(text: string): Promise.<Array.<leadfoot/Element>>
Gets all elements in the currently active window/frame partially matching the given case-insensitive link text.
Parameters
| Name | Type | Description |
|---|---|---|
text |
string |
The partial link text of the element. |
Source
findAllByTagName(tagName: string): Promise.<Array.<leadfoot/Element>>
Gets all elements in the currently active window/frame matching the given HTML tag name.
Parameters
| Name | Type | Description |
|---|---|---|
tagName |
string |
The tag name of the element. |
Source
findAllByXpath(path: string): Promise.<Array.<leadfoot/Element>>
Gets all elements in the currently active window/frame matching the given XPath selector.
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
The XPath selector to search for. |
Source
findByClassName(className: string): Promise.<leadfoot/Element>
Gets the first element in the currently active window/frame matching the given CSS class name.
Parameters
| Name | Type | Description |
|---|---|---|
className |
string |
The CSS class name to search for. |
Source
findByCssSelector(selector: string): Promise.<leadfoot/Element>
Gets the first element in the currently active window/frame matching the given CSS selector.
Parameters
| Name | Type | Description |
|---|---|---|
selector |
string |
The CSS selector to search for. |
Source
findById(id: string): Promise.<leadfoot/Element>
Gets the first element in the currently active window/frame matching the given ID.
Parameters
| Name | Type | Description |
|---|---|---|
id |
string |
The ID of the element. |
Source
findByLinkText(text: string): Promise.<leadfoot/Element>
Gets the first element in the currently active window/frame matching the given case-insensitive link text.
Parameters
| Name | Type | Description |
|---|---|---|
text |
string |
The link text of the element. |
Source
findByName(name: string): Promise.<leadfoot/Element>
Gets the first element in the currently active window/frame matching the given name attribute.
Parameters
| Name | Type | Description |
|---|---|---|
name |
string |
The name of the element. |
Source
findByPartialLinkText(text: string): Promise.<leadfoot/Element>
Gets the first element in the currently active window/frame partially matching the given case-insensitive link text.
Parameters
| Name | Type | Description |
|---|---|---|
text |
string |
The partial link text of the element. |
Source
findByTagName(tagName: string): Promise.<leadfoot/Element>
Gets the first element in the currently active window/frame matching the given HTML tag name.
Parameters
| Name | Type | Description |
|---|---|---|
tagName |
string |
The tag name of the element. |
Source
findByXpath(path: string): Promise.<leadfoot/Element>
Gets the first element in the currently active window/frame matching the given XPath selector.
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
The XPath selector to search for. |
Source
findDisplayed(using: string, value: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element in the currently active window/frame matching the given query. This is inherently slower than leadfoot/Session#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
| Name | Type | Description |
|---|---|---|
using |
string |
The element retrieval strategy to use. See leadfoot/Session#find for options. |
value |
string |
The strategy-specific value to search for. See leadfoot/Session#find for details. |
Source
findDisplayedByClassName(className: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element in the currently active window/frame matching the given CSS class name. This is inherently slower than leadfoot/Session#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
| Name | Type | Description |
|---|---|---|
className |
string |
The CSS class name to search for. |
Source
findDisplayedByCssSelector(selector: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element in the currently active window/frame matching the given CSS selector. This is inherently slower than leadfoot/Session#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
| Name | Type | Description |
|---|---|---|
selector |
string |
The CSS selector to search for. |
Source
findDisplayedById(id: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element in the currently active window/frame matching the given ID. This is inherently slower than leadfoot/Session#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
| Name | Type | Description |
|---|---|---|
id |
string |
The ID of the element. |
Source
findDisplayedByLinkText(text: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element in the currently active window/frame matching the given case-insensitive link text. This is inherently slower than leadfoot/Session#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
| Name | Type | Description |
|---|---|---|
text |
string |
The link text of the element. |
Source
findDisplayedByName(name: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element in the currently active window/frame matching the given name attribute. This is inherently slower than leadfoot/Session#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
| Name | Type | Description |
|---|---|---|
name |
string |
The name of the element. |
Source
findDisplayedByPartialLinkText(text: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element in the currently active window/frame partially matching the given case-insensitive link text. This is inherently slower than leadfoot/Session#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
| Name | Type | Description |
|---|---|---|
text |
string |
The partial link text of the element. |
Source
findDisplayedByTagName(tagName: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element in the currently active window/frame matching the given HTML tag name. This is inherently slower than leadfoot/Session#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
| Name | Type | Description |
|---|---|---|
tagName |
string |
The tag name of the element. |
Source
findDisplayedByXpath(path: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element in the currently active window/frame matching the given XPath selector. This is inherently slower than leadfoot/Session#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
The XPath selector to search for. |
Source
flickFinger(element: leadfoot/Element, xOffset: number, yOffset: number, speed: number): Promise.<void>
Flicks a finger. Note that this method is currently badly specified and highly dysfunctional and is only provided for the sake of completeness.
Parameters
| Name | Type | Description |
|---|---|---|
element |
leadfoot/Element |
The element where the flick should start. |
xOffset |
number |
The x-offset in pixels to flick by. |
yOffset |
number |
The x-offset in pixels to flick by. |
speed |
number |
The speed of the flick, in pixels per second. Most human flicks are 100–200ms, so this value will be higher than expected. |
Source
get(url: string): Promise.<void>
Navigates the focused window/frame to a new URL.
Parameters
| Name | Type |
|---|---|
url |
string |
Source
getActiveElement(): Promise.<leadfoot/Element>
getActiveImeEngine(): Promise.<string>
Gets the currently active input method editor for the remote environment. As of April 2014, no known remote environments support IME functions.
Source
getAlertText(): Promise.<string>
getAllWindowHandles(): Promise.<Array.<string>>
getApplicationCacheStatus(): Promise.<number>
Gets the current state of the HTML5 application cache for the current page.
Returns
The cache status. One of 0 (uncached), 1 (cached/idle), 2 (checking), 3 (downloading), 4 (update ready), 5 (obsolete).
Source
getAttribute(name: string): Promise.<string>
Gets an attribute of the element.
Parameters
| Name | Type | Description |
|---|---|---|
name |
string |
The name of the attribute. |
Returns
The value of the attribute, or
nullif no such attribute exists.
See
- Element#getProperty to retrieve an element property.
Source
getAvailableImeEngines(): Promise.<Array.<string>>
Gets a list of input method editor engines available to the remote environment. As of April 2014, no known remote environments support IME functions.
Source
getAvailableLogTypes(): Promise.<Array.<string>>
Gets the types of logs that are currently available for retrieval from the remote environment.
Source
getComputedStyle(propertyName: string): Promise.<string>
Gets a CSS computed property value for the element.
Parameters
| Name | Type | Description |
|---|---|---|
propertyName |
string |
The CSS property to retrieve. This argument must be hyphenated, not camel-case. |
Source
getCookies(): Promise.<Array.<WebDriverCookie>>
getCurrentUrl(): Promise.<string>
getCurrentWindowHandle(): Promise.<string>
Gets the identifier for the window that is currently focused.
Returns
A window handle identifier that can be used with other window handling functions.
Source
getExecuteAsyncTimeout(): Promise.<number>
getFindTimeout(): Promise.<number>
getGeolocation(): Promise.<Geolocation>
Gets the current geographical location of the remote environment.
Returns
Latitude and longitude are specified using standard WGS84 decimal latitude/longitude. Altitude is specified as meters above the WGS84 ellipsoid. Not all environments support altitude.
Source
getLocalStorageItem(key: string): Promise.<string>
Gets a value from local storage for the focused window/frame.
Parameters
| Name | Type | Description |
|---|---|---|
key |
string |
The key of the data to get. |
Source
getLocalStorageKeys(): Promise.<Array.<string>>
Gets the list of keys set in local storage for the focused window/frame.
Source
getLocalStorageLength(): Promise.<number>
Gets the number of keys set in local storage for the focused window/frame.
Source
getLogsFor(type: string): Promise.<Array.<LogEntry>>
Gets all logs from the remote environment of the given type. The logs in the remote environment are cleared once they have been retrieved.
Parameters
| Name | Type | Description |
|---|---|---|
type |
string |
The type of log entries to retrieve. Available log types differ between remote environments. Use leadfoot/Session#getAvailableLogTypes to learn what log types are currently available. Not all environments support all possible log types. |
Returns
An array of log entry objects. Timestamps in log entries are Unix timestamps, in seconds.
Source
getOrientation(): Promise.<string>
Gets the current screen orientation.
Returns
Either 'portrait' or 'landscape'.
Source
getPageLoadTimeout(): Promise.<number>
getPageSource(): Promise.<string>
Gets the HTML loaded in the focused window/frame. This markup is serialised by the remote environment so may not exactly match the HTML provided by the Web server.
Source
getPageTitle(): Promise.<string>
Gets the title of the top-level browsing context of the current window or tab.
Source
getPosition(): Promise.<{x: number, y: number}>
Gets the position of the element relative to the top-left corner of the document, taking into account scrolling and CSS transformations (if they are supported).
Source
getProperty(name: string): Promise.<any>
Gets a property of the element.
Parameters
| Name | Type | Description |
|---|---|---|
name |
string |
The name of the property. |
Returns
The value of the property.
See
- Element#getAttribute to retrieve an element attribute.
Source
getSessionStorageItem(key: string): Promise.<string>
Gets a value from session storage for the focused window/frame.
Parameters
| Name | Type | Description |
|---|---|---|
key |
string |
The key of the data to get. |
Source
getSessionStorageKeys(): Promise.<Array.<string>>
Gets the list of keys set in session storage for the focused window/frame.
Source
getSessionStorageLength(): Promise.<number>
Gets the number of keys set in session storage for the focused window/frame.
Source
getSize(): Promise.<{width: number, height: number}>
Gets the size of the element, taking into account CSS transformations (if they are supported).
Source
getSpecAttribute(name: string): Promise.<string>
Gets a property or attribute of the element according to the WebDriver specification algorithm. Use of this method is not recommended; instead, use leadfoot/Element#getAttribute to retrieve DOM attributes and leadfoot/Element#getProperty to retrieve DOM properties.
This method uses the following algorithm on the server to determine what value to return:
- If
nameis 'style', returns thestyle.cssTextproperty of the element. - If the attribute exists and is a boolean attribute, returns 'true' if the attribute is true, or null otherwise.
- If the element is an
<option>element andnameis 'value', returns thevalueattribute if it exists, otherwise returns the visible text content of the option. - If the element is a checkbox or radio button and
nameis 'selected', returns 'true' if the element is checked, or null otherwise. - If the returned value is expected to be a URL (e.g. element is
<a>and attribute ishref), returns the fully resolved URL from thehref/srcproperty of the element, not the attribute. - If
nameis 'class', returns theclassNameproperty of the element. - If
nameis 'readonly', returns 'true' if thereadOnlyproperty is true, or null otherwise. - If
namecorresponds to a property of the element, and the property is not an Object, return the property value coerced to a string. - If
namecorresponds to an attribute of the element, return the attribute value.
Parameters
| Name | Type | Description |
|---|---|---|
name |
string |
The property or attribute name. |
Returns
The value of the attribute as a string, or
nullif no such property or attribute exists.
Source
getTagName(): Promise.<string>
Gets the tag name of the element. For HTML documents, the value is always lowercase.
Source
getTimeout(type: string): Promise.<number>
Gets the current value of a timeout for the session.
Parameters
| Name | Type | Description |
|---|---|---|
type |
string |
The type of timeout to retrieve. One of 'script', 'implicit', or 'page load'. |
Returns
The timeout, in milliseconds.
Source
getVisibleText(): Promise.<string>
Gets the visible text within the element. <br> elements are converted to line breaks in the returned
text, and whitespace is normalised per the usual XML/HTML whitespace normalisation rules.
Source
getWindowPosition(windowHandleopt: string): Promise.<{x: number, y: number}>
Gets the position of a window.
Note that this method is not part of the W3C WebDriver standard.
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
windowHandle |
string | optional |
The name of the window to query. See leadfoot/Session#switchToWindow to learn about valid window names. Omit this argument to query the currently focused window. |
Returns
An object describing the position of the window, in CSS pixels, relative to the top-left corner of the primary monitor. If a secondary monitor exists above or to the left of the primary monitor, these values will be negative.
Source
getWindowSize(windowHandleopt: string): Promise.<{width: number, height: number}>
Gets the dimensions of a window.
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
windowHandle |
string | optional |
The name of the window to query. See leadfoot/Session#switchToWindow to learn about valid window names. Omit this argument to query the currently focused window. |
Returns
An object describing the width and height of the window, in CSS pixels.
Source
goBack(): Promise.<void>
Navigates the focused window/frame back one page using the browser’s navigation history.
Source
goForward(): Promise.<void>
Navigates the focused window/frame forward one page using the browser’s navigation history.
Source
isDisplayed(): Promise.<boolean>
Returns whether or not the element would be visible to an actual user. This means that the following types of elements are considered to be not displayed:
- Elements with
display: none - Elements with
visibility: hidden - Elements positioned outside of the viewport that cannot be scrolled into view
- Elements with
opacity: 0 - Elements with no
offsetWidthoroffsetHeight
Source
isEnabled(): Promise.<boolean>
isImeActivated(): Promise.<boolean>
Returns whether or not an input method editor is currently active in the remote environment. As of April 2014, no known remote environments support IME functions.
Source
isSelected(): Promise.<boolean>
Returns whether or not a form element is currently selected (for drop-down options and radio buttons), or whether or not the element is currently checked (for checkboxes).
Source
longTap(element: leadfoot/Element): Promise.<void>
Performs a long-tap gesture on an element.
Parameters
| Name | Type | Description |
|---|---|---|
element |
leadfoot/Element |
The element to long-tap. |
Source
maximizeWindow(windowHandleopt: string): Promise.<void>
Maximises a window according to the platform’s window system behaviour.
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
windowHandle |
string | optional |
The name of the window to resize. See leadfoot/Session#switchToWindow to learn about valid window names. Omit this argument to resize the currently focused window. |
Source
moveFinger(x: number, y: number): Promise.<void>
Moves the last depressed finger to a new point on the touch screen.
Parameters
| Name | Type | Description |
|---|---|---|
x |
number |
The screen x-coordinate to move to, maybe in device pixels. |
y |
number |
The screen y-coordinate to move to, maybe in device pixels. |
Source
moveMouseTo(elementopt: Element, xOffsetopt: number, yOffsetopt: number): Promise.<void>
Moves the remote environment’s mouse cursor to the specified element or relative position. If the element is outside of the viewport, the remote driver will attempt to scroll it into view automatically.
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
element |
Element | optional |
The element to move the mouse to. If x-offset and y-offset are not specified, the mouse will be moved to the centre of the element. |
xOffset |
number | optional |
The x-offset of the cursor, maybe in CSS pixels, relative to the left edge of the specified element’s bounding client rectangle. If no element is specified, the offset is relative to the previous position of the mouse, or to the left edge of the page’s root element if the mouse was never moved before. |
yOffset |
number | optional |
The y-offset of the cursor, maybe in CSS pixels, relative to the top edge of the specified element’s bounding client rectangle. If no element is specified, the offset is relative to the previous position of the mouse, or to the top edge of the page’s root element if the mouse was never moved before. |
Source
pressFinger(x: number, y: number): Promise.<void>
Depresses a new finger at the given point on a touch screen device without releasing it.
Parameters
| Name | Type | Description |
|---|---|---|
x |
number |
The screen x-coordinate to press, maybe in device pixels. |
y |
number |
The screen y-coordinate to press, maybe in device pixels. |
Source
pressKeys(keys: string|Array.<string>): Promise.<void>
Types into the focused window/frame/element.
Parameters
| Name | Type | Description |
|---|---|---|
keys |
string|Array.<string> |
The text to type in the remote environment. It is possible to type keys that do not have normal character
representations (modifier keys, function keys, etc.) as well as keys that have two different representations
on a typical US-ASCII keyboard (numpad keys); use the values from leadfoot/keys to type these
special characters. Any modifier keys that are activated by this call will persist until they are
deactivated. To deactivate a modifier key, type the same modifier key a second time, or send |
Source
pressMouseButton(buttonopt: number): Promise.<void>
Depresses a mouse button without releasing it.
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
button |
number | optional |
The button to press. See leadfoot/Session#click for available options. |
Source
quit(): Promise.<void>
Terminates the session. No more commands will be accepted by the remote after this point.
Source
refresh(): Promise.<void>
releaseFinger(x: number, y: number): Promise.<void>
Releases whatever finger exists at the given point on a touch screen device.
Parameters
| Name | Type | Description |
|---|---|---|
x |
number |
The screen x-coordinate where a finger is pressed, maybe in device pixels. |
y |
number |
The screen y-coordinate where a finger is pressed, maybe in device pixels. |
Source
releaseMouseButton(buttonopt: number): Promise.<void>
Releases a previously depressed mouse button.
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
button |
number | optional |
The button to press. See leadfoot/Session#click for available options. |
Source
setCookie(cookie: WebDriverCookie): Promise.<void>
setExecuteAsyncTimeout(ms: number): Promise.<void>
Sets the timeout for leadfoot/Session#executeAsync calls.
Parameters
| Name | Type | Description |
|---|---|---|
ms |
number |
The length of the timeout, in milliseconds. |
Source
setFindTimeout(ms: number): Promise.<void>
Sets the timeout for leadfoot/Session#find calls.
Parameters
| Name | Type | Description |
|---|---|---|
ms |
number |
The length of the timeout, in milliseconds. |
Source
setGeolocation(location: Geolocation): Promise.<void>
Sets the geographical location of the remote environment.
Parameters
| Name | Type | Description |
|---|---|---|
location |
Geolocation |
Latitude and longitude are specified using standard WGS84 decimal latitude/longitude. Altitude is specified as meters above the WGS84 ellipsoid. Not all environments support altitude. |
Source
setLocalStorageItem(key: string, value: string): Promise.<void>
Sets a value in local storage for the focused window/frame.
Parameters
| Name | Type | Description |
|---|---|---|
key |
string |
The key to set. |
value |
string |
The value to set. |
Source
setOrientation(orientation: string): Promise.<void>
Sets the screen orientation.
Parameters
| Name | Type | Description |
|---|---|---|
orientation |
string |
Either 'portrait' or 'landscape'. |
Source
setPageLoadTimeout(ms: number): Promise.<void>
Sets the timeout for leadfoot/Session#get calls.
Parameters
| Name | Type | Description |
|---|---|---|
ms |
number |
The length of the timeout, in milliseconds. |
Source
setSessionStorageItem(key: string, value: string): Promise.<void>
Sets a value in session storage for the focused window/frame.
Parameters
| Name | Type | Description |
|---|---|---|
key |
string |
The key to set. |
value |
string |
The value to set. |
Source
setTimeout(type: string, ms: number): Promise.<void>
Sets the value of a timeout for the session.
Parameters
| Name | Type | Description |
|---|---|---|
type |
string |
The type of timeout to set. One of 'script', 'implicit', or 'page load'. |
ms |
number |
The length of time to use for the timeout, in milliseconds. A value of 0 will cause operations to time out immediately. |
Source
setWindowPosition(windowHandleopt: string, x: number, y: number): Promise.<void>
Sets the position of a window.
Note that this method is not part of the W3C WebDriver standard.
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
windowHandle |
string | optional |
The name of the window to move. See leadfoot/Session#switchToWindow to learn about valid window names. Omit this argument to move the currently focused window. |
x |
number |
The screen x-coordinate to move to, in CSS pixels, relative to the left edge of the primary monitor. |
|
y |
number |
The screen y-coordinate to move to, in CSS pixels, relative to the top edge of the primary monitor. |
Source
setWindowSize(windowHandleopt: string, width: number, height: number): Promise.<void>
Sets the dimensions of a window.
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
windowHandle |
string | optional |
The name of the window to resize. See leadfoot/Session#switchToWindow to learn about valid window names. Omit this argument to resize the currently focused window. |
width |
number |
The new width of the window, in CSS pixels. |
|
height |
number |
The new height of the window, in CSS pixels. |
Source
sleep(ms: number): leadfoot/Command.<void>
Pauses execution of the next command in the chain for ms milliseconds.
Parameters
| Name | Type | Description |
|---|---|---|
ms |
number |
Time to delay, in milliseconds. |
Source
submit(): Promise.<void>
Submits the element, if it is a form, or the form belonging to the element, if it is a form element.
Source
switchToFrame(id: string|number|null|Element): Promise.<void>
Switches the currently focused frame to a new frame.
Parameters
| Name | Type | Description |
|---|---|---|
id |
string|number|null|Element |
The frame to switch to. In most environments, a number or string value corresponds to a key in the
|
Source
switchToParentFrame(): Promise.<void>
Switches the currently focused frame to the parent of the currently focused frame.
Source
switchToWindow(handle: string): Promise.<void>
Switches the currently focused window to a new window.
Parameters
| Name | Type | Description |
|---|---|---|
handle |
string |
The handle of the window to switch to. In mobile environments and environments based on the W3C WebDriver standard, this should be a handle as returned by leadfoot/Session#getAllWindowHandles. In environments using the JsonWireProtocol, this value corresponds to the |
Source
takeScreenshot(): Promise.<Buffer>
Gets a screenshot of the focused window and returns it in PNG format.
Returns
A buffer containing a PNG image.
Source
tap(element: leadfoot/Element): Promise.<void>
Taps an element on a touch screen device. If the element is outside of the viewport, the remote driver will attempt to scroll it into view automatically.
Parameters
| Name | Type | Description |
|---|---|---|
element |
leadfoot/Element |
The element to tap. |
Source
then(callbackopt: function, errbackopt: function): leadfoot/Command.<any>
Adds a callback to be invoked once the previously chained operation has completed.
This method is compatible with the Promise#then API, with two important differences:
- The context (
this) of the callback is set to the Command object, rather than beingundefined. This allows promise helpers to be created that can retrieve the appropriate session and element contexts for execution. - A second non-standard
setContextargument is passed to the callback. ThissetContextfunction can be called at any time before the callback fulfills its return value and expects either a single leadfoot/Element or an array of Elements to be provided as its only argument. The provided element(s) will be used as the context for subsequent element method invocations (click, etc.). If thesetContextmethod is not called, the element context from the parent will be passed through unmodified.
Parameters
| Name | Type | Attributes |
|---|---|---|
callback |
function | optional |
errback |
function | optional |
Source
touchScroll(elementopt: Element, xOffsetopt: number, yOffsetopt: number): Promise.<void>
Scrolls the currently focused window on a touch screen device.
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
element |
Element | optional |
An element to scroll to. The window will be scrolled so the element is as close to the top-left corner of the window as possible. |
xOffset |
number | optional |
An optional x-offset, relative to the left edge of the element, in CSS pixels. If no element is specified, the offset is relative to the previous scroll position of the window. |
yOffset |
number | optional |
An optional y-offset, relative to the top edge of the element, in CSS pixels. If no element is specified, the offset is relative to the previous scroll position of the window. |
Source
type(value: string|Array.<string>): Promise.<void>
Types into the element. This method works the same as the leadfoot/Session#pressKeys method except that any modifier keys are automatically released at the end of the command. This method should be used instead of leadfoot/Session#pressKeys to type filenames into file upload fields.
Since 1.5, if the WebDriver server supports remote file uploads, and you type a path to a file on your local computer, that file will be transparently uploaded to the remote server and the remote filename will be typed instead. If you do not want to upload local files, use leadfoot/Session#pressKeys instead.
Parameters
| Name | Type | Description |
|---|---|---|
value |
string|Array.<string> |
The text to type in the remote environment. See leadfoot/Session#pressKeys for more information. |
Source
typeInPrompt(text: string|Array.<string>): Promise.<void>
Types into the currently active prompt pop-up.
Parameters
| Name | Type | Description |
|---|---|---|
text |
string|Array.<string> |
The text to type into the pop-up’s input box. |
Source
waitForDeletedByClassName(className: string): Promise.<void>
Waits for all elements in the currently active window/frame matching the given CSS class name to be destroyed.
Parameters
| Name | Type | Description |
|---|---|---|
className |
string |
The CSS class name to search for. |
Source
waitForDeletedByCssSelector(selector: string): Promise.<void>
Waits for all elements in the currently active window/frame matching the given CSS selector to be destroyed.
Parameters
| Name | Type | Description |
|---|---|---|
selector |
string |
The CSS selector to search for. |
Source
waitForDeletedById(id: string): Promise.<void>
Waits for all elements in the currently active window/frame matching the given ID to be destroyed.
Parameters
| Name | Type | Description |
|---|---|---|
id |
string |
The ID of the element. |
Source
waitForDeletedByLinkText(text: string): Promise.<void>
Waits for all elements in the currently active window/frame matching the given case-insensitive link text to be destroyed.
Parameters
| Name | Type | Description |
|---|---|---|
text |
string |
The link text of the element. |
Source
waitForDeletedByName(name: string): Promise.<void>
Waits for all elements in the currently active window/frame matching the given name attribute to be destroyed.
Parameters
| Name | Type | Description |
|---|---|---|
name |
string |
The name of the element. |
Source
waitForDeletedByPartialLinkText(text: string): Promise.<void>
Waits for all elements in the currently active window/frame partially matching the given case-insensitive link text to be destroyed.
Parameters
| Name | Type | Description |
|---|---|---|
text |
string |
The partial link text of the element. |
Source
waitForDeletedByTagName(tagName: string): Promise.<void>
Waits for all elements in the currently active window/frame matching the given HTML tag name to be destroyed.
Parameters
| Name | Type | Description |
|---|---|---|
tagName |
string |
The tag name of the element. |
Source
waitForDeletedByXpath(path: string): Promise.<void>
Waits for all elements in the currently active window/frame matching the given XPath selector to be destroyed.
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
The XPath selector to search for. |