leadfoot/Session
Inheritance
- leadfoot/Session
- Object
new (require("leadfoot/Session"))(sessionId: string, server: leadfoot/Server, capabilities: Capabilities)
A Session represents a connection to a remote environment that can be driven programmatically.
Parameters
Name | Type | Description |
---|---|---|
sessionId |
string |
The ID of the session, as provided by the remote. |
server |
leadfoot/Server |
The server that the session belongs to. |
capabilities |
Capabilities |
A map of bugs and features that the remote environment exposes. |
Source
All Properties
Property | Defined by |
---|---|
(readonly)
Information about the available features and bugs in the remote environment. |
leadfoot/Session |
(readonly)
The Server that the session runs on. |
leadfoot/Session |
sessionId: string
(readonly)
The current session ID. |
leadfoot/Session |
All Methods
Method | Defined by |
---|---|
_manualFindByLinkText(using: string, value: string, multiple: boolean, elementnullable: Element): Element|Array.<Element>
Searches a document or element subtree for links with the given normalized text. |
leadfoot/Session |
Normalize whitespace in the same way that most browsers generate innerText. |
leadfoot/Session |
Accepts an alert, prompt, or confirmation pop-up. |
leadfoot/Session |
Activates an input method editor in the remote environment. |
leadfoot/Session |
Clears all cookies for the current page. |
leadfoot/Session |
Clears all data in local storage for the focused window/frame. |
leadfoot/Session |
Clears all data in session storage for the focused window/frame. |
leadfoot/Session |
Clicks a mouse button at the point where the mouse cursor is currently positioned. |
leadfoot/Session |
Closes the currently focused window. |
leadfoot/Session |
Deactivates any active input method editor in the remote environment. |
leadfoot/Session |
Deletes a cookie on the current page. |
leadfoot/Session |
Deletes a value from local storage for the focused window/frame. |
leadfoot/Session |
Deletes a value from session storage for the focused window/frame. |
leadfoot/Session |
Dismisses an alert, prompt, or confirmation pop-up. |
leadfoot/Session |
Double-clicks the primary mouse button. |
leadfoot/Session |
Performs a double-tap gesture on an element. |
leadfoot/Session |
Executes JavaScript code within the focused window/frame. |
leadfoot/Session |
Executes JavaScript code within the focused window/frame. |
leadfoot/Session |
Gets the first element from the focused window/frame that matches the given query. |
leadfoot/Session |
Gets an array of elements from the focused window/frame that match the given query. |
leadfoot/Session |
Gets all elements in the currently active window/frame matching the given CSS class name. |
leadfoot/Session |
Gets all elements in the currently active window/frame matching the given CSS selector. |
leadfoot/Session |
Gets all elements in the currently active window/frame matching the given case-insensitive link text. |
leadfoot/Session |
Gets all elements in the currently active window/frame matching the given name attribute. |
leadfoot/Session |
Gets all elements in the currently active window/frame partially matching the given case-insensitive link text. |
leadfoot/Session |
Gets all elements in the currently active window/frame matching the given HTML tag name. |
leadfoot/Session |
Gets all elements in the currently active window/frame matching the given XPath selector. |
leadfoot/Session |
Gets the first element in the currently active window/frame matching the given CSS class name. |
leadfoot/Session |
Gets the first element in the currently active window/frame matching the given CSS selector. |
leadfoot/Session |
Gets the first element in the currently active window/frame matching the given ID. |
leadfoot/Session |
Gets the first element in the currently active window/frame matching the given case-insensitive link text. |
leadfoot/Session |
Gets the first element in the currently active window/frame matching the given name attribute. |
leadfoot/Session |
Gets the first element in the currently active window/frame partially matching the given case-insensitive link text. |
leadfoot/Session |
Gets the first element in the currently active window/frame matching the given HTML tag name. |
leadfoot/Session |
Gets the first element in the currently active window/frame matching the given XPath selector. |
leadfoot/Session |
Gets the first displayed element in the currently active window/frame matching the given query. |
leadfoot/Session |
Gets the first displayed element in the currently active window/frame matching the given CSS class name. |
leadfoot/Session |
Gets the first displayed element in the currently active window/frame matching the given CSS selector. |
leadfoot/Session |
Gets the first displayed element in the currently active window/frame matching the given ID. |
leadfoot/Session |
Gets the first displayed element in the currently active window/frame matching the given case-insensitive link text. |
leadfoot/Session |
Gets the first displayed element in the currently active window/frame matching the given name attribute. |
leadfoot/Session |
Gets the first displayed element in the currently active window/frame partially matching the given case-insensitive link text. |
leadfoot/Session |
Gets the first displayed element in the currently active window/frame matching the given HTML tag name. |
leadfoot/Session |
Gets the first displayed element in the currently active window/frame matching the given XPath selector. |
leadfoot/Session |
flickFinger(element: leadfoot/Element, xOffset: number, yOffset: number, speed: number): Promise.<void>
Flicks a finger. |
leadfoot/Session |
Navigates the focused window/frame to a new URL. |
leadfoot/Session |
Gets the currently focused element from the focused window/frame. |
leadfoot/Session |
Gets the currently active input method editor for the remote environment. |
leadfoot/Session |
Gets the text displayed in the currently active alert pop-up. |
leadfoot/Session |
Gets a list of identifiers for all currently open windows. |
leadfoot/Session |
Gets the current state of the HTML5 application cache for the current page. |
leadfoot/Session |
Gets a list of input method editor engines available to the remote environment. |
leadfoot/Session |
Gets the types of logs that are currently available for retrieval from the remote environment. |
leadfoot/Session |
Gets all cookies set on the current page. |
leadfoot/Session |
Gets the URL that is loaded in the focused window/frame. |
leadfoot/Session |
Gets the identifier for the window that is currently focused. |
leadfoot/Session |
Gets the timeout for leadfoot/Session#executeAsync calls. |
leadfoot/Session |
Gets the timeout for leadfoot/Session#find calls. |
leadfoot/Session |
Gets the current geographical location of the remote environment. |
leadfoot/Session |
Gets a value from local storage for the focused window/frame. |
leadfoot/Session |
Gets the list of keys set in local storage for the focused window/frame. |
leadfoot/Session |
Gets the number of keys set in local storage for the focused window/frame. |
leadfoot/Session |
Gets all logs from the remote environment of the given type. |
leadfoot/Session |
Gets the current screen orientation. |
leadfoot/Session |
Gets the timeout for leadfoot/Session#get calls. |
leadfoot/Session |
Gets the HTML loaded in the focused window/frame. |
leadfoot/Session |
Gets the title of the top-level browsing context of the current window or tab. |
leadfoot/Session |
Gets a value from session storage for the focused window/frame. |
leadfoot/Session |
Gets the list of keys set in session storage for the focused window/frame. |
leadfoot/Session |
Gets the number of keys set in session storage for the focused window/frame. |
leadfoot/Session |
Gets the current value of a timeout for the session. |
leadfoot/Session |
Gets the position of a window. |
leadfoot/Session |
Gets the dimensions of a window. |
leadfoot/Session |
Navigates the focused window/frame back one page using the browser’s navigation history. |
leadfoot/Session |
Navigates the focused window/frame forward one page using the browser’s navigation history. |
leadfoot/Session |
Returns whether or not an input method editor is currently active in the remote environment. |
leadfoot/Session |
Performs a long-tap gesture on an element. |
leadfoot/Session |
Maximises a window according to the platform’s window system behaviour. |
leadfoot/Session |
Moves the last depressed finger to a new point on the touch screen. |
leadfoot/Session |
Moves the remote environment’s mouse cursor to the specified element or relative position. |
leadfoot/Session |
Depresses a new finger at the given point on a touch screen device without releasing it. |
leadfoot/Session |
Types into the focused window/frame/element. |
leadfoot/Session |
Depresses a mouse button without releasing it. |
leadfoot/Session |
Terminates the session. |
leadfoot/Session |
Reloads the current browser window/frame. |
leadfoot/Session |
Releases whatever finger exists at the given point on a touch screen device. |
leadfoot/Session |
Releases a previously depressed mouse button. |
leadfoot/Session |
Sets a cookie on the current page. |
leadfoot/Session |
Sets the timeout for leadfoot/Session#executeAsync calls. |
leadfoot/Session |
Sets the timeout for leadfoot/Session#find calls. |
leadfoot/Session |
Sets the geographical location of the remote environment. |
leadfoot/Session |
Sets a value in local storage for the focused window/frame. |
leadfoot/Session |
Sets the screen orientation. |
leadfoot/Session |
Sets the timeout for leadfoot/Session#get calls. |
leadfoot/Session |
Sets a value in session storage for the focused window/frame. |
leadfoot/Session |
Sets the value of a timeout for the session. |
leadfoot/Session |
Sets the position of a window. |
leadfoot/Session |
Sets the dimensions of a window. |
leadfoot/Session |
Switches the currently focused frame to a new frame. |
leadfoot/Session |
Switches the currently focused frame to the parent of the currently focused frame. |
leadfoot/Session |
Switches the currently focused window to a new window. |
leadfoot/Session |
Gets a screenshot of the focused window and returns it in PNG format. |
leadfoot/Session |
Taps an element on a touch screen device. |
leadfoot/Session |
Scrolls the currently focused window on a touch screen device. |
leadfoot/Session |
Types into the currently active prompt pop-up. |
leadfoot/Session |
Waits for all elements in the currently active window/frame to be destroyed. |
leadfoot/Session |
Waits for all elements in the currently active window/frame matching the given CSS class name to be destroyed. |
leadfoot/Session |
Waits for all elements in the currently active window/frame matching the given CSS selector to be destroyed. |
leadfoot/Session |
Waits for all elements in the currently active window/frame matching the given ID to be destroyed. |
leadfoot/Session |
Waits for all elements in the currently active window/frame matching the given case-insensitive link text to be destroyed. |
leadfoot/Session |
Waits for all elements in the currently active window/frame matching the given name attribute to be destroyed. |
leadfoot/Session |
Waits for all elements in the currently active window/frame partially matching the given case-insensitive link text to be destroyed. |
leadfoot/Session |
Waits for all elements in the currently active window/frame matching the given HTML tag name to be destroyed. |
leadfoot/Session |
Waits for all elements in the currently active window/frame matching the given XPath selector to be destroyed. |
leadfoot/Session |
Properties
(readonly) capabilities: Capabilities
Information about the available features and bugs in the remote environment.
Source
(readonly) server: leadfoot/Server
(readonly) sessionId: string
Methods
_manualFindByLinkText(using: string, value: string, multiple: boolean, elementnullable: Element): Element|Array.<Element>
Searches a document or element subtree for links with the given normalized text. This method works for 'link text' and 'partial link text' search strategies.
Note that this method should be passed to an execute
call, not called directly.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
using |
string |
The strategy in use ('link text' or 'partial link text') |
|
value |
string |
The link text to search for |
|
multiple |
boolean |
If true, return all matching links |
|
element |
Element | nullable |
A context element |
Returns
The found element or elements
Source
_normalizeWhitespace(text: string): string
Normalize whitespace in the same way that most browsers generate innerText.
Parameters
Name | Type |
---|---|
text |
string |
Returns
Text with leading and trailing whitespace removed, with inner runs of spaces changed to a single space, and with "\r\n" pairs converted to "\n".
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
clearCookies(): Promise.<void>
clearLocalStorage(): Promise.<void>
clearSessionStorage(): Promise.<void>
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
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
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
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
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
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
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
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
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
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
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
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
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
waitForDeleted(using: string, value: string): Promise.<void>
Waits for all elements in the currently active window/frame to be destroyed.
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
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. |