To learn more about using JavaScript in LeanFT, see Setting up and working with the JavaScript SDK.
For JavaScript code samples, see Code Samples - JavaScript.

BrowserTO

Web. BrowserTO

new BrowserTO()

A tab in an open Web browser. Note: To open a new browser tab, use: Web.Browser.launch. To access a browser that is already open, use: Web.Browser.attach.

Members

displayName

Returns the object display name defined in the Application Model.

Methods

$(selector, objTypeopt) → {*}

Creates a child test object of this test object. This operation does not cause LeanFT to search for the object in the AUT. LeanFT interacts with the application only when a step runs that performs an operation on the AUT object.
Parameters:
Name Type Attributes Default Description
selector Description | string The description of the test object. Can be a full test object description or a string. If a string is provided, it is interpreted as a CSS selector with a default test object type of WebElement.
objType Description <optional>
Web.Element() The type of test object to use when supplying a CSS string for the selector.
Overrides:
Returns:
the new child test object with the provided description.
Type
*

$$(a, dontFilterByTypeopt) → {Promise.<Array.<TestObject>>}

Returns all child objects of this object that match the supplied test object description.
Parameters:
Name Type Attributes Default Description
a Description | string description object that defines the test object type and the set of properties and values that should be common to all objects that are returned.
dontFilterByType bool <optional>
false Set this parameter to true to avoid limiting the returned objects to a specific test object type.
Overrides:
Returns:
an array of test objects that match the supplied description.
Type
Promise.<Array.<TestObject>>

$x(xpath, childTypeopt) → {*}

Creates a child test object of this test object. This operation does not cause LeanFT to search for the object in the AUT. LeanFT interacts with the application only when a step runs that performs an operation on the AUT object.
Parameters:
Name Type Attributes Default Description
xpath string The xpath of the element that will be used to search for the test object.
childType Description <optional>
Web.Element() The child type.
Returns:
the new child test object with the provided xpath as its description.
Type
*

absoluteLocation() → {Promise.<Point>}

Returns the object's absolute coordinates relative to the screen (in pixels), format: {x,y}.
Remark: 0,0 is always the top-left corner of the (primary) monitor.
Returns:
a promise that is fulfilled when the object's absolute coordinates are returned.
Type
Promise.<Point>

back() → {Promise.<void>}

Navigates to the previous page in the browser history list.
Note: This method is identical to clicking the browser's Back button.
Returns:
a promise that is fulfilled when the browser has performed the back operation.
Type
Promise.<void>

clearCache() → {Promise.<void>}

Clears the browser cache.
Note: This method does not clear the browser's cookies. Use deleteCookies() to delete the cookies.
Returns:
a promise that is fulfilled after the browser's cache is cleared.
Type
Promise.<void>

close() → {Promise.<void>}

Closes the browser window (or tab) that this test object represents.
Returns:
a promise that is fulfilled when the browser has performed the close operation.
Type
Promise.<void>

closeAllTabs() → {Promise.<void>}

Closes all tabs (if any) and closes the browser window.
Use the close() method to close only the currently open tab.

Limitation: Your Internet Explorer (IE) browser must be configured to "Always close all tabs". To do this, open two or more tabs in IE. Then close IE. In the message box that pops up, select the "Always close all tabs" option.

Note: This method is not supported on Chrome. Use the Close method instead.
Returns:
a promise that is fulfilled after all tabs (if any) are closed in the browser.
Type
Promise.<void>

deleteCookies(originopt) → {Promise.<void>}

Parameters:
Name Type Attributes Description
origin string <optional>
The full or partial domain of the source.
If no arguments are passed: Deletes all cookies from the browser.
If an argument is passed: Deletes only cookies that originated from the browser source.
For example, entering MySite.com or MySite.net clears cookies only from the specified site, whereas entering MySite clears cookies from all related domains.
Note: This method does not clear the browser's cache. Use clearCache() to clear the cache.
Returns:
a promise that is fulfilled after deleting the cookies.
Type
Promise.<void>

description() → {*}

Returns the description for this test object.
Returns:
the description for this test object.
Type
*

embedScript(scriptToEmbed, functionName) → {Promise.<void>}

Runs this JavaScript each time a page or frame loads or refreshes in the browser.
Note:
- The script remains embedded until you close the browser, or until the run session ends.
- Using this method to perform alert operations may result in unexpected behavior.
- To run this method, the security settings in your Web browser must be set to allow active scripting; otherwise, steps using this method will fail.
Parameters:
Name Type Description
scriptToEmbed function | String The full content of the JavaScript to embed.
functionName String Optional: the name of the function.
Returns:
a promise that is fulfilled after the script has been embedded.
Type
Promise.<void>

exists(timeoutopt) → {Promise.<bool>}

Checks whether this object exists in the AUT.
Parameters:
Name Type Attributes Description
timeout Number <optional>
The time (in seconds) to wait for this object before returning a result of true or false.
By default, uses the object synchronization timeout defined in the runtime engine settings.
Returns:
an indication of whether the object exists.
Type
Promise.<bool>

forward() → {Promise.<void>}

Navigates to the next page in the browser history list. Note: This method is identical to clicking the browser's Forward button.
Returns:
a promise that is fulfilled after the browser navigates to the next page in the browser history list.
Type
Promise.<void>

fullScreen() → {Promise.<void>}

Displays the browser in full-screen mode.
Returns:
a promise that is fulfilled after the browser has been displayed in full screen mode.
Type
Promise.<void>

getDialogText() → {Promise.<void>}

Returns the text displayed in a browser message box, such as an alert, confirmation, or prompt.
Returns:
a promise that is fulfilled after the text displayed in a browser message box, such as an alert, confirmation, or prompt has been captured.
Type
Promise.<void>

getTextLocations(text, rectangleopt) → {Promise.<object>}

Returns all rectangular areas containing the specified text within this object.
Parameters:
Name Type Attributes Description
text String The text to search for in the test object.
rectangle Object <optional>
The rectangular area in the test object to search for the text.
Returns:
a promise that is fulfilled with an array of rectangles containing all rectangular areas containing the specified text within this object.
Type
Promise.<object>

getVisibleText(rectangleopt) → {Promise.<string>}

Returns all visible text from this object.
Parameters:
Name Type Attributes Description
rectangle Object <optional>
The rectangular area in the test object to return the text from.
Returns:
a promise that is fulfilled with all the visible text from this object.
Type
Promise.<string>

handleDialog(dialogAction) → {Promise.<void>}

Clicks a button on the alert, confirmation, or prompt message box.
Parameters:
Name Type Description
dialogAction Web.DialogButton The button to click. Default: OK
Returns:
a promise that is fulfilled after clicking the dialog button.
Type
Promise.<void>

handlePromptDialog(text) → {Promise.<void>}

Enters text in the browser's prompt message box and clicks the OK button.
Parameters:
Name Type Description
text String The text to enter in the edit field.
Returns:
that will be fulfilled after editing the field and clicking on the OK button in the dialog.
Type
Promise.<void>

hasDialog() → {Promise.<void>}

Indicates whether the browser message box is currently open.
Returns:
that will be notified whether the browser message box is currently open.
Type
Promise.<void>

highlight() → {Promise.<void>}

Highlights this object in the AUT.
Remark: This may be useful when debugging a test.
Returns:
a promise that is fulfilled when the highlighting operation ends.
Type
Promise.<void>

highlightMatches(description, dontFilterByTypeopt) → {Promise.<Number>}

Highlights all children that match the supplied test object description.
Parameters:
Name Type Attributes Default Description
description A description object that defines the test object type and the set of properties and values that should be common to all objects that are highlighted.
dontFilterByType bool <optional>
false Set this parameter to true to avoid limiting the highlighted objects to a specific test object type.
Returns:
the number of matches that are found and highlighted.
Type
Promise.<Number>

location() → {Promise.<Point>}

Returns the object's coordinates relative to the parent window (in pixels), format: {x,y}.
Returns:
a promise that is fulfilled when the object's relative coordinates are returned.
Type
Promise.<Point>
Opens the specified URL in the browser.
Parameters:
Name Type Description
url string The URL to open.
Returns:
a promise that is fulfilled when the navigate operation was performed.
Type
Promise.<void>

numberOfTabs() → {Promise.<Number>}

Returns the number of tabs currently open in the browser.
Returns:
a promise that is fulfilled with the number of tabs currently open in the browser.
Type
Promise.<Number>

openNewTab() → {Promise.<void>}

Opens a new tab in the browser window.
Returns:
a promise that is fulfilled after a new tab opened in the browser.
Type
Promise.<void>

openTitle() → {Promise.<string>}

Returns the browser's initial title when first opened.
Returns:
a promise that is fulfilled with the browser's initial title when first opened.
Type
Promise.<string>

openUrl() → {Promise.<String>}

Return the URL from which the browser is opened.
Returns:
a promise that is fulfilled with the URL from which the browser is opened.
Type
Promise.<String>

parent() → {*}

Returns the parent test object of this test object.
Returns:
the parent test object of this test object.
Type
*

refresh() → {Promise.<void>}

Refreshes the current page.
Note: This method is identical to clicking the browser's Refresh button.
Returns:
a promise that is fulfilled after the current page refreshes.
Type
Promise.<void>

resizeTo(sizeOrWidth, heightopt) → {Promise.<void>}

Resizes the browser window to the specified dimensions.
Parameters:
Name Type Attributes Description
sizeOrWidth Size | Number If a Size object is passed, it will resize according to the object. If a number is passed, it will be interpreted as a width.
height Number <optional>
If the first parameter is a full Size object, this parameter is ignored.
Returns:
a promise that is fulfilled after resizing the browser.
Type
Promise.<void>

size() → {Promise.<Size>}

Returns the object's size (in pixels).
Returns:
a promise that is fulfilled when the object's size is returned.
Type
Promise.<Size>

snapshot(optionsopt) → {Promise.<string>}

Captures and returns a Base64 representation of this test object.
Parameters:
Name Type Attributes Description
options Object <optional>
An options object that defines the image capture preferences.
Properties
Name Type Attributes Default Description
format string <optional>
"png" The format of the image. Possible values: png, bmp.
Returns:
a promise that is fulfilled with the Base64 string of the test object's image.
Type
Promise.<string>

sync() → {Promise.<void>}

Waits for the browser to complete the current navigation.
Note: You can use this method to instruct your test to wait until the browser is loaded.
Returns:
a promise that is fulfilled after the browser completes the current navigation.
Type
Promise.<void>

title() → {Promise.<String>}

Returns the browser title.
Returns:
a promise that is fulfilled with the browser title.
Type
Promise.<String>

url() → {Promise.<String>}

Returns the browser URL.
Returns:
a promise that is fulfilled with the browser URL.
Type
Promise.<String>

verifyImageExists(imageToFind, similarityopt) → {Promise.<object>}

Checks whether a snapshot of this object contains the supplied image.
Parameters:
Name Type Attributes Description
imageToFind String A Base64 string representation of the image to look for within the test object's snapshot.
similarity Number <optional>
The minimum similarity between the two images (as a percentage), above which the find is considered a match. Default = 100.
Returns:
a promise that is fulfilled with an object representing the point where the image was located, or null if it was not found.
Type
Promise.<object>

verifyImageMatch(expectedImage, maskAreaImage, pixelToleranceopt, rgbToleranceopt) → {Promise.<Boolean>}

Checks whether a snapshot of this object and the supplied image are a match.
Parameters:
Name Type Attributes Description
expectedImage String A Base64 string representation of the image to compare to the test object snapshot.
maskAreaImage String A Base64 string representation of the image mask area to use in the image comparison.
pixelTolerance Number <optional>
The percentage of pixels that can differ between the two images, and still be considered a match. Default = 0.
rgbTolerance Number <optional>
The percentage by which the RGB values of the pixels in the two images can differ, and still be considered a match. Default = 0.
Returns:
a Boolean representing the comparison result.
Type
Promise.<Boolean>

version() → {Promise.<Web.BrowserVersion>}

Information about the browser.
Returns:
a promise that is fulfilled with the information about the browser.
Type
Promise.<Web.BrowserVersion>