Chain Class
Chain Interface for Taxi
Missing a function?
File an issue with us or create your own function by doing something like this before a Taxi instance is created:
taxi.Chain.prototype.elementClick = function (selector, button, callBack) {
// Find elements with the selector
return this.elements(selector, function (element) {
// Make sure that evaluation will work for sync and async mode
return this.driver().utils().when(
// Click on the selected element with the object-oriented API
element.mouse().click(button),
// When it is done, execute the callback function in the correct scope,
// additionally giving the element as its first parameter
function () {
return this._scopeCallBack(callBack, [element]);
}.bind(this)
);
}.bind(this));
});
Always make sure that you return the values along the way!
This is a complete implementation of the elementClick
function in this API.
Constructor
Item Index
Methods
- _driverAction
- _elementAction
- _logMethodCall
- _requestJSON
- _scopeCallBack
- activateFrame
- activateParentFrame
- activateWindow
- activeElement
- adjust
- backward
- captureArea
- captureDocument
- captureViewPort
- click
- closeWindow
- compareArea
- compareDocument
- compareViewPort
- dblClick
- dialogAccept
- dialogDismiss
- dialogSendKeys
- dialogText
- driver
- elementAbsoluteCenter
- elementAttribute
- elementCapture
- elementClasses
- elementClear
- elementClick
- elementClickAt
- elementCompare
- elementCssValue
- elementDblClick
- elementDblClickAt
- elementDblTap
- elementFrame
- elementHasClass
- elementHasText
- elementHover
- elementHoverAt
- elementIsDisplayed
- elementIsEnabled
- elementIsSelected
- elementLocation
- elementLocationInView
- elementLongTap
- elementRelativeCenter
- elements
- elementSendKeys
- elementSize
- elementSubmit
- elementTagName
- elementTap
- elementText
- elementTouch
- elementTouchAt
- elementValue
- end
- forward
- getDriver
- hover
- location
- maximize
- navigateTo
- refresh
- relocate
- resize
- scrollBy
- scrollLocation
- scrollTo
- sendKeys
- size
- sleep
- source
- title
- url
- waitForElementDisplay
- waitForElementNotDisplayed
- waitForElementNotPresent
- waitForElementPresent
- windows
Methods
_driverAction
-
value
-
fn
Convenience function to execute driver actions
Parameters:
-
value
Value that needs to be evaluated
-
fn
FunctionFunction that needs to be triggered with evaluated value
Returns:
The chain object
_elementAction
-
selector
-
fn
Convenience function to execute element actions
Parameters:
Returns:
The chain object
_requestJSON
-
method
-
path
-
[body]
Performs a context dependent JSON request for the current session. The result is parsed for errors.
Returns:
_scopeCallBack
-
cb
-
args
Convenience function to handle scope for chains
Parameters:
-
cb
FunctionCallback function that should be triggered with the correct scope
-
args
List of arguments to supply to the callback function
Returns:
The chain object
activateFrame
-
id
-
[callBack]
Activates one of the available frames within the currently active document
Parameters:
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
activateParentFrame
-
[callBack]
Activates the parent frame (i.e. the document) when a frame was previously activated.
Parameters:
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
activateWindow
-
id
-
[callBack]
Activates a window, switching the currently active document
If you have multiple documents, you need to switch to each in turn to interact with them. You can only interact with the currently active document. That is where this function call comes in handy.
Parameters:
Returns:
The chain object
Callback function
function (
browser
)
Scope
{
Chain
}
Parameters
browser
{Browser
} - The browser session
activeElement
-
[callBack]
Activates a selected element
Parameters:
-
[callBack]
Function optionalCallback function that will be triggered with the currently active element
Returns:
The chain object
Callback function
function (
element
,active
Window)
Scope
{
Chain
}
Parameters
element
{Element
} - Currently active element in the active browser documentactiveWindow
{ActiveWindow
} - Active browser document/window
adjust
-
[options]
-
[callBack]
Adjusts the configurations according to the browsers behavior.
Note: This is needed especially when screenshots should be taken since browsers behave here very different from each other.
Needs to be called only once per taxi instance.
Parameters:
-
[options]
Object optionalPreparation options for chaining
-
[url='http://www.example.org']
Int optionalDefault website for adjustment for browser
-
[horizontalPadding=0]
Int optionalPadding of the document
-
-
[callBack]
Function optionalCallback function that will be triggered with each selected element in turn
Returns:
backward
-
[callBack]
Goes backward in the document history, equivalent to a user pressing the back button within the browser
Parameters:
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
captureArea
-
[x=0]
-
[y=0]
-
[width=document.width-x]
-
[height=document.height-y]
-
[options]
-
[callBack]
Captures a selected area in a PNG buffer
Parameters:
-
[x=0]
Int optionalX-coordinate for area. Uses the left corner of the document as default.
-
[y=0]
Int optionalY-coordinate for area. Uses the top corner of the document as default.
-
[width=document.width-x]
Int optionalWidth of area to be captured. Uses the rest width of the document as the default.
-
[height=document.height-y]
Int optionalHeight of area to be captured. Uses the rest height of the document as the default.
-
[options]
Object optionalOptions for taking the screenshots. See elementCapture for more information on the screenshot options.
-
[eachFn]
Function optionalWill execute the function on client before each screenshot is taken
-
[completeFn]
Function optionalWill execute the function on client after all screenshots are taken
-
[blockOuts]
Object[] | Element[] | String[] optionalList of areas/elements that should be blocked-out
-
[blockOutColor=black]
Object optionalColor to be used for blocking-out areas {red, green, blue, alpha}
-
[wait=100]
Int optionalWait in ms before each screenshot
-
-
[callBack]
Function optionalCallback function that will be triggered with the image-buffer of the area screenshot
Returns:
The chain object
Callback function
function (
imageBuffer
,element
,index
)
Scope
{
Chain
}
Parameters
imageBuffer
{Buffer
} - Binary buffer of the PNG imageelement
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
captureDocument
-
[options]
-
[callBack]
Captures the complete document in a PNG buffer
Parameters:
-
[options]
Object optionalOptions for taking the screenshots. See elementCapture for more information on the screenshot options.
-
[eachFn]
Function optionalWill execute the function on client before each screenshot is taken
-
[completeFn]
Function optionalWill execute the function on client after all screenshots are taken
-
[blockOuts]
Object[] | Element[] | String[] optionalList of areas/elements that should be blocked-out
-
[blockOutColor=black]
Object optionalColor to be used for blocking-out areas {red, green, blue, alpha}
-
[wait=100]
Int optionalWait in ms before each screenshot
-
-
[callBack]
Function optionalCallback function that will be triggered with the image-buffer of the document screenshot
Returns:
The chain object
Callback function
function (
imageBuffer
,element
,index
)
Scope
{
Chain
}
Parameters
imageBuffer
{Buffer
} - Binary buffer of the PNG imageelement
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
captureViewPort
-
[options]
-
[callBack]
Captures the current view-port in a PNG buffer
Parameters:
-
[options]
Object optionalOptions for taking the screenshots. See elementCapture for more information on the screenshot options.
-
[eachFn]
Function optionalWill execute the function on client before each screenshot is taken
-
[completeFn]
Function optionalWill execute the function on client after all screenshots are taken
-
[blockOuts]
Object[] | Element[] | String[] optionalList of areas/elements that should be blocked-out
-
[blockOutColor=black]
Object optionalColor to be used for blocking-out areas {red, green, blue, alpha}
-
[wait=100]
Int optionalWait in ms before each screenshot
-
-
[callBack]
Function optionalCallback function that will be triggered with the image-buffer of the view-port screenshot
Returns:
The chain object
Callback function
function (
imageBuffer
,element
,index
)
Scope
{
Chain
}
Parameters
imageBuffer
{Buffer
} - Binary buffer of the PNG imageelement
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
click
-
x
-
y
-
[button=Mouse.BUTTON_LEFT]
-
[callBack]
Clicks on the active document at the specified absolute coordinates
Parameters:
-
x
IntAbsolute x-coordinate to click on
-
y
IntAbsolute y-coordinate to click on
-
[button=Mouse.BUTTON_LEFT]
Int optionalButton that should be pressed when click action is executed.
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
Note
You can use the constants available in the mouse-object or submit the following values:
- 0 - Left Button
- 1 - Middle Button
- 2 - Right Button
closeWindow
-
[callBack]
Closes the currently active window, switching the focus to the next available window
Parameters:
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
compareArea
-
title
-
[x=0]
-
[y=0]
-
[width=document.width-x]
-
[height=document.height-y]
-
[options]
-
[callBack]
Compares a specific and fixed area of the document with previously captured images
Parameters:
-
title
StringTitle of the comparison
-
[x=0]
Int optionalX-coordinate for area. Uses the left corner of the document as default.
-
[y=0]
Int optionalY-coordinate for area. Uses the top corner of the document as default.
-
[width=document.width-x]
Int optionalWidth of area to be captured. Uses the rest width of the document as the default.
-
[height=document.height-y]
Int optionalHeight of area to be captured. Uses the rest height of the document as the default.
-
[options]
Object optionalOptions for the screenshots and compare the data. See elementCapture for more information on the screenshot options.
-
[eachFn]
Function optionalWill execute the function on client before each screenshot is taken
-
[completeFn]
Function optionalWill execute the function on client after all screenshots are taken
-
[blockOuts]
Object[] | Element[] | String[] optionalList of areas/elements that should be blocked-out
-
[blockOutColor=black]
Object optionalColor to be used for blocking-out areas {red, green, blue, alpha}
-
[wait=100]
Int optionalWait in ms before each screenshot
-
[compare]
Object optionalOptions for the comparison. See the Blink-Diff documentation
-
[id=1]
Object optionalAdditional identifier to differentiate comparison
-
-
-
[callBack]
Function optionalCallback function that will be triggered with the result fo the request
Returns:
The chain object
Callback function
function (
isSimilar
,activeWindow
)
Scope
{
Chain
}
Parameters
isSimilar
{boolean|null
} - Is comparison similar to previous one?activeWindow
{ActiveWindow
} - Active browser document/window
Notes
See elementCompare for more information on the comparison options.
compareDocument
-
title
-
[options]
-
[callBack]
Compares the whole document with images that were captured previously
Parameters:
-
title
StringTitle of the comparison
-
[options]
Object optionalOptions for the screenshots and compare the data. See elementCapture for more information on the screenshot options.
-
[eachFn]
Function optionalWill execute the function on client before each screenshot is taken
-
[completeFn]
Function optionalWill execute the function on client after all screenshots are taken
-
[blockOuts]
Object[] | Element[] | String[] optionalList of areas/elements that should be blocked-out
-
[blockOutColor=black]
Object optionalColor to be used for blocking-out areas {red, green, blue, alpha}
-
[wait=100]
Int optionalWait in ms before each screenshot
-
[compare]
Object optionalOptions for the comparison. See the Blink-Diff documentation
-
[id=1]
Object optionalAdditional identifier to differentiate comparison
-
-
-
[callBack]
Function optionalCallback function that will be triggered with the reuslt of the request
Returns:
The chain object
Callback function
function (
isSimilar
,activeWindow
)
Scope
{
Chain
}
Parameters
isSimilar
{boolean|null
} - Is comparison similar to previous one?activeWindow
{ActiveWindow
} - Active browser document/window
Notes
See elementCompare for more information on the comparison options.
compareViewPort
-
title
-
[options]
-
[callBack]
Compares the view-port with images previously taken
Parameters:
-
title
StringTitle of the comparison
-
[options]
Object optionalOptions for the screenshots and compare the data. See elementCapture for more information on the screenshot options.
-
[eachFn]
Function optionalWill execute the function on client before each screenshot is taken
-
[completeFn]
Function optionalWill execute the function on client after all screenshots are taken
-
[blockOuts]
Object[] | Element[] | String[] optionalList of areas/elements that should be blocked-out
-
[blockOutColor=black]
Object optionalColor to be used for blocking-out areas {red, green, blue, alpha}
-
[wait=100]
Int optionalWait in ms before each screenshot
-
[compare]
Object optionalOptions for the comparison. See the Blink-Diff documentation
-
[id=1]
Object optionalAdditional identifier to differentiate comparison
-
-
-
[callBack]
Function optionalCallback function that will be triggered with the result of the request
Returns:
The chain object
Callback function
function (
isSimilar
,activeWindow
)
Scope
{
Chain
}
Parameters
isSimilar
{boolean|null
} - Is comparison similar to previous one?activeWindow
{ActiveWindow
} - Active browser document/window
Notes
See elementCompare for more information on the comparison options.
dblClick
-
x
-
y
-
[button=Mouse.BUTTON_LEFT]
-
[callBack]
Double-clicks on the active document at the specified absolute coordinates
Parameters:
-
x
IntAbsolute x-coordinate to double-click on
-
y
IntAbsolute y-coordinate to double-click on
-
[button=Mouse.BUTTON_LEFT]
Int optionalButton that should be pressed when click action is executed.
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
Note
You can use the constants available in the mouse-object or submit the following values:
- 0 - Left Button
- 1 - Middle Button
- 2 - Right Button
dialogAccept
-
[callBack]
Accepts the currently displayed dialog
In most cases, this will be the "OK" button.
Parameters:
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
Note This dialog could be an alert, a prompt, or any other browser dialog that the browser supports.
dialogDismiss
-
[callBack]
Dismisses the currently displayed dialog
In most cases, this will be the "Cancel" button.
Parameters:
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
Note This dialog could be an alert, a prompt, or any other browser dialog that the browser supports.
dialogSendKeys
-
keys
-
[callBack]
Sends a string or a list of key-strokes to the currently displayed dialog.
This is useful when there is a prompt()
currently open, requesting user input.
Parameters:
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
Note This dialog could be an alert, a prompt, or any other browser dialog that the browser supports.
dialogText
-
[callBack]
Determines the text content of the currently displayed dialog
Parameters:
-
[callBack]
Function optionalCallback function that will be triggered with the text-content of the dialog
Returns:
The chain object
Callback function
function (
text
,activeWindow
)
Scope
{
Chain
}
Parameters
text
{string
} - Text content of the currently displayed dialogactiveWindow
{ActiveWindow
} - Active browser document/window
Note This dialog could be an alert, a prompt, or any other browser dialog that the browser supports.
driver
()
Driver
Gets the driver object.
Returns:
Example:
driver === driver.chain().driver() // true
elementAbsoluteCenter
-
selector
-
[callBack]
Determines the absolute coordinates of the center of the selected elements
Parameters:
Returns:
The chain object
Callback function
function (
coordinates
,element
,index
)
Scope
{
Chain
}
Parameters
coordinates
{object
} - Absolute coordinates of the center of the selected elementx
{int
} - Absolute x-coordinate of the selected elements centery
{int
} - Absolute y-coordinate of the selected elements center
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementAttribute
-
selector
-
attribute
-
[callBack]
Retrieves the attribute value of the selected elements
Parameters:
Returns:
The chain object
Example:
// Determines the value of all input tags and prints them out to the console.
driver.elementAttribute('input', 'value', function (value) {
console.log(value);
});
Callback function
function (
value
,element
,index
)
Scope
{
Chain
}
Parameters
value
{string
} - Value of attributeelement
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementCapture
-
selector
-
[options]
-
[callBack]
Captures an element in a PNG buffer, discarding or ignoring the rest of the document from the image
Parameters:
-
selector
StringCSS selector of DOM elements
-
[options]
Object optionalOptions for taking the screenshot
-
[eachFn]
Function optionalWill execute the function on client before each screenshot is taken
-
[completeFn]
Function optionalWill execute the function on client after all screenshots are taken
-
[blockOuts]
Object[] | Element[] | String[] optionalList of areas/elements that should be blocked-out
-
[blockOutColor=black]
Object optionalColor to be used for blocking-out areas {red, green, blue, alpha}
-
[wait=100]
Int optionalWait in ms before each screenshot
-
[allPadding]
Int optionalPadding for all sides
-
[hPadding]
Int optionalPadding on left and right side of the element
-
[vPadding]
Int optionalPadding on the top and on the bottom of the element
-
[leftPadding]
Int optionalPadding on the left of the element
-
[rightPadding]
Int optionalPadding on the right of the element
-
[topPadding]
Int optionalPadding on the top of the element
-
[bottomPadding]
Int optionalPadding on the bottom of the element
-
-
[callBack]
Function optionalCallback function that will be triggered with the image-buffer of the screenshot from the selected element
Returns:
The chain object
Callback function
function (
imageBuffer
,element
,index
)
Scope
{
Chain
}
Parameters
imageBuffer
{Buffer
} - Binary buffer of the PNG imageelement
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
options.eachFn (index
)
This function is executed on the client-side just before a new screenshot is taken. How often this function is executed depends on the browser and should only be used to prepare for screenshots (i.e. removing a floating header on the second image).
Scope
{
document.window
} - within the browser
Parameters
index
{int
} - Zero-based index of screenshot that will be taken
Note Since this function is executed on the client, it will not be able to capture variables in the lexical scope. The function will be serialized, sent to the client, de-serialized, and executed without knowing the context of its initial definition.
options.completeFn ()
This function is executed on the client-side just after all screenshots were taken. This function will only be called once and it can be used to revert changes applied to the document during eachFn calls (i.e. re-attaching a floating header).
Scope
{
document.window
} - within the browser
Parameters
none
Note Since this function is executed on the client, it will not be able to capture variables in the lexical scope. The function will be serialized, sent to the client, de-serialized, and executed without knowing the context of its initial definition.
options.blockOuts
Sometimes, you want to block-out areas on a screenshot, be it for censoring purposes or for comparison during multiple test-runs with every changing data (i.e. date/time label). In this list, you can supply CSS selectors, a list of already selected elements, or even a list of pre-defined fixed areas. All of these different "selectors" can be combined in the same list.
CSS Selector
The supplied CSS selector will be used to find single or multiple DOM element in the document. Taxi will flatten the list whenever multiple items are found.
Element Selector
These are objects that were already selected previously and re-used for this purpose.
Static object
This object holds static information about the location and the size of the area to block-out.
The object has following properties:
x
{int
} - X-coordinate of the areay
{int
} - Y-coordinate of the areawidth
{int
} - Width of the areaheight
{int
} - Height of the area[color]
{object
} - Custom block-out color for this area only. See options.blockOutColor for more information.
options.blockOutColor
This is the default color for all block-out areas that do not have custom colors.
Properties
[red]
{int
} - Red component of the color for blocking-out the area. Accepted values are from 0-255. 0 means that there is no intensity of this component within the resulting color; 255 is the full intensity.[green]
{int
} - Green component of the color for blocking-out the area. Accepted values are from 0-255. 0 means that there is no intensity of this component within the resulting color; 255 is the full intensity.[blue]
{int
} - Blue component of the color for blocking-out the area. Accepted values are from 0-255. 0 means that there is no intensity of this component within the resulting color; 255 is the full intensity.[alpha]
{int
} - Alpha channel of the color for blocking-out the area. Accepted values are from 0.0-1.0. 0 means that there is no intensity of this component within the resulting color; 1.0 is the full intensity.
options.wait
Sometimes, it is required to slow-down the screen-capturing process. By default, Taxi will wait 100 milliseconds before each screenshot to make sure that changes caused by the scrolling behavior were applied in the browser view-port. Extend this time if the screenshot needs special behavior.
options.*padding
Padding that reaches outside of the document itself will be reduced to the extend of the document.
elementClasses
-
selector
-
[callBack]
Determines a list of classes assigned to the selected elements
Parameters:
Returns:
The chain object
Example:
// Prints a comma-separated list of classes that the element with the id "search" has.
driver.elementClasses('#search', function (classes) {
console.log(classes.join(', '));
});
Callback function
function (
classes
,element
,index
)
Scope
{
Chain
}
Parameters
classes
{string[]
} - List of classes of the selected elementelement
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementClear
-
selector
-
[callBack]
Clears the contents of the selected elements
Note This will only work on elements that can be cleared like input boxes and text areas.
Parameters:
Returns:
The chain object
Callback function
function (
element
,index
)
Scope
{
Chain
}
Parameters
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementClick
-
selector
-
[button=Mouse.BUTTON_LEFT]
-
[callBack]
Clicks on the selected elements
Parameters:
Returns:
The chain object
Callback function
function (
element
,index
)
Scope
{
Chain
}
Parameters
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
Note
You can use the constants available in the mouse-object or submit the following values:
- 0 - Left Button
- 1 - Middle Button
- 2 - Right Button
elementClickAt
-
selector
-
xOffset
-
yOffset
-
[button=Mouse.BUTTON_LEFT]
-
[callBack]
Clicks on a specific coordinate relative to the upper-left corner of the selected elements
Parameters:
-
selector
StringCSS selector of DOM elements
-
xOffset
IntX-offset relative to the left corner of the selected element
-
yOffset
IntY-offset relative to the top corner of the selected element
-
[button=Mouse.BUTTON_LEFT]
Int optionalButton that should be pressed when click action is executed.
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
element
,index
)
Scope
{
Chain
}
Parameters
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
Note
You can use the constants available in the mouse-object or submit the following values:
- 0 - Left Button
- 1 - Middle Button
- 2 - Right Button
elementCompare
-
selector
-
title
-
[options]
-
[callBack]
Compares the image of selected elements from previous captures/comparisons
Parameters:
-
selector
StringCSS selector of DOM elements
-
title
StringTitle of the comparison
-
[options]
Object optionalOptions for the screenshots and compare the data. See elementCapture for more information on the screenshot options.
-
[eachFn]
Function optionalWill execute the function on client before each screenshot is taken
-
[completeFn]
Function optionalWill execute the function on client after all screenshots are taken
-
[blockOuts]
Object[] | Element[] | String[] optionalList of areas/elements that should be blocked-out
-
[blockOutColor=black]
Object optionalColor to be used for blocking-out areas {red, green, blue, alpha}
-
[wait=100]
Int optionalWait in ms before each screenshot
-
[compare]
Object optionalOptions for the comparison. See the Blink-Diff documentation
-
[id=1]
Object optionalAdditional identifier to differentiate comparison
-
-
[allPadding]
Int optionalPadding for all sides
-
[hPadding]
Int optionalPadding on left and right side of the element
-
[vPadding]
Int optionalPadding on the top and on the bottom of the element
-
[leftPadding]
Int optionalPadding on the left of the element
-
[rightPadding]
Int optionalPadding on the right of the element
-
[topPadding]
Int optionalPadding on the top of the element
-
[bottomPadding]
Int optionalPadding on the bottom of the element
-
-
[callBack]
Function optionalCallback function that will be triggered with the result of the request
Returns:
The chain object
Callback function
function
(isSimilar
,element
,index
)
Scope
{
Chain
}
Parameters
isSimilar
{boolean
|null
} - Is comparison similar to previous one?element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
Notes
isSimilar
will be NULL when the value cannot be determined at the time of comparison due to the comparison process, or simply because there was no previous image to compare to.isSimilar
will be true when all of the comparison APIs determined a similarity to previously captured data, depending on the configuration setting for each of those comparison APIs.isSimilar
will be false when at least one comparison API determines a difference in the current and previous state.
Notes
title
The title needs to be unique to identify each of these comparisons across all test-runs. Additionally, the id parameter can be used to make this identifier unique.options.compare.id
The id will be added to the title to get a unique identifier.
Comparison configuration
General comparison options can be set globally in the driver through the setValue
/getValue
methods.
The options for the comparison, however, need to be supplied for every comparison itself.
Changing configuration options
driver.setValue('blinkDiff.outputOnSuccess', true);
Options
blinkDiff.outputOnSuccess
{boolean
} [default=true] - Should an output be created when comparison is successful? There will always be an output if the comparison fails.blinkDiff.failOnDifference
{boolean
} [default=true] - Should Taxi trigger an error when a difference is recognized?blinkDiff.autoApprove
{boolean
} [default=false] - Should Taxi auto-approve screenshots when no previous comparison exist? Otherwise, the test will ignore this comparison, saving the current build screenshot.blinkDiff.approvedPath
{string
} [default=cwd] - Path to the approved folder. Defaults to the current working directory.blinkDiff.buildPath
{string
} [default=approvedPath] - Path to the build folder, holding all the screenshots taken in the recent build. Defaults to the approved folder.blinkDiff.diffPath
{string
} [default=buildPath] - Path to the difference folder, keeping the highlighted differences between the approved image and the build image. Default to the build folder.blinkDiff.options
{object
} - Default values for Blink-Diff options. See the Blink-Diff documentationblinkDiff.batchFailures
{boolean
} [default=false] - Failures are batched to the end of the tests when this flag is set.blinkDiff.failOnAdditions
{boolean
} [default=false] - Fail when no approved screenshot is found.
elementCssValue
-
selector
-
property
-
[callBack]
Determines the value of a CSS property for each selected element
Note Use the original CSS property name according to the CSS standard, not the JavaScript naming convention for CSS properties.
Parameters:
Returns:
The chain object
Callback function
function (
value
,element
,index
)
Scope
{
Chain
}
Parameters
value
{string
} - Value of the requested CSS-property of the selected elementelement
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementDblClick
-
selector
-
[button=Mouse.BUTTON_LEFT]
-
[callBack]
Double-clicks on the selected elements
Parameters:
Returns:
The chain object
Callback function
function (
element
,index
)
Scope
{
Chain
}
Parameters
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
Note
You can use the constants available in the mouse-object or submit the following values:
- 0 - Left Button
- 1 - Middle Button
- 2 - Right Button
elementDblClickAt
-
selector
-
xOffset
-
yOffset
-
[button=Mouse.BUTTON_LEFT]
-
[callBack]
Double-clicks on a specific coordinate relative to the upper-left corner of the selected elements
Parameters:
-
selector
StringCSS selector of DOM elements
-
xOffset
IntX-offset relative to the left corner of the selected element
-
yOffset
IntY-offset relative to the top corner of the selected element
-
[button=Mouse.BUTTON_LEFT]
Int optionalButton that should be pressed when click action is executed.
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
element
,index
)
Scope
{
Chain
}
Parameters
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
Note
You can use the constants available in the mouse-object or submit the following values:
- 0 - Left Button
- 1 - Middle Button
- 2 - Right Button
elementDblTap
-
selector
-
[callBack]
Double-taps on the selected elements
Parameters:
Returns:
The chain object
Callback function
function (
element
,index
)
Scope
{
Chain
}
Parameters
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementFrame
-
selector
-
[callBack]
Determines the absolute location and size of the selected elements
Parameters:
Returns:
The chain object
Callback function
function (
frame
,element
,index
)
Scope
{
Chain
}
Parameters
frame
{object
} - Absolute coordinates and size of the selected elementx
{int
} - Absolute x-coordinate of the selected elementy
{int
} - Absolute y-coordinate of the selected elementwidth
{int
} - Width of the selected elementheight
{int
} - Height of the selected element
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementHasClass
-
selector
-
className
-
[callBack]
Checks if the selected elements have a specific class
Parameters:
Returns:
The chain object
Example:
// Selects all input tags, checking if they have the "name" class,
// and printing out the value of the input element when they have the class.
driver.elementHasClass('input', 'name', function (hasClass, element) {
if (hasClass) {
console.log(element.getValue());
}
});
Callback function
function (
hasClass
,element
,index
)
Scope
{
Chain
}
Parameters
hasClass
{boolean
} - Does the selected element have the supplied class-name?element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementHasText
-
selector
-
text
-
[callBack]
Determines if selected elements have a string or even a sub-string in their text content
Parameters:
Returns:
The chain object
Example:
// Checks if the article synopsis has the word "Lion" in it.
driver.elementHasText('.synopsis', 'Lion', function (hasText) {
if (hasText) {
console.log('Found "Lion" in the synopsis!');
}
});
Callback function
function (
hasText
,element
,index
)
Scope
{
Chain
}
Parameters
hasText
{boolean
} - Does selected element have the supplied text as string or substring?element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
Note
The text search is case sensitive. If you want case insensitivity, then please use regular expressions.
(i.e. /
elementHover
-
selector
-
[callBack]
Hovers the mouse over the selected elements
Parameters:
Returns:
The chain object
Callback function
function (
element
,index
)
Scope
{
Chain
}
Parameters
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementHoverAt
-
selector
-
xOffset
-
yOffset
-
[callBack]
Hovers the mouse over a specific coordinate relative to the upper-left corner of the selected elements
Parameters:
Returns:
The chain object
Callback function
function (
element
,index
)
Scope
{
Chain
}
Parameters
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementIsDisplayed
-
selector
-
[callBack]
Checks if the selected elements are displayed somewhere on the page
Parameters:
Returns:
The chain object
Callback function
function (
isDisplayed
,element
,index
)
Scope
{
Chain
}
Parameters
isDisplayed
{boolean
} - Is the selected element displayed?element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementIsEnabled
-
selector
-
[callBack]
Checks if the selected elements are enabled
Parameters:
Returns:
The chain object
Callback function
function (
isEnabled
,element
,index
)
Scope
{
Chain
}
Parameters
isEnabled
{boolean
} - Is the selected element enabled?element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementIsSelected
-
selector
-
[callBack]
Checks if the selected elements are checked
Note This function will only work on elements which have a "checked"-value (i.e. checkbox, radiobox, or options element).
Parameters:
Returns:
The chain object
Callback function
function (
isSelected
,element
,index
)
Scope
{
Chain
}
Parameters
isSelected
{boolean
} - Is the selected element checked/selected?element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementLocation
-
selector
-
[callBack]
Determines the absolute location of the selected elements
Parameters:
Returns:
The chain object
Callback function
function (
location
,element
,index
)
Scope
{
Chain
}
Parameters
location
{object
} - Absolute location of the selected elementx
{int
} - Absolute x-coordinate of the selected elementy
{int
} - Absolute y-coordinate of the selected element
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementLocationInView
-
selector
-
[callBack]
Determines the location of the selected elements relative to the current view-ports top-left corner
Parameters:
Returns:
The chain object
Callback function
function (
location
,element
,index
)
Scope
{
Chain
}
Parameters
location
{object
} - Location of the selected element relative to the view-portx
{int
} - X-coordinate of the selected element relative to the view-porty
{int
} - Y-coordinate of the selected element relative to the view-port
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementLongTap
-
selector
-
[callBack]
Triggers a long-tap on the selected elements
Parameters:
Returns:
The chain object
Callback function
function (
element
,index
)
Scope
{
Chain
}
Parameters
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementRelativeCenter
-
selector
-
[callBack]
Determines the coordinates of the center of the selected elements relative to the elements top-left corner
Parameters:
Returns:
The chain object
Callback function
function (
coordinates
,element
,index
)
Scope
{
Chain
}
Parameters
coordinates
{object
} - Coordinates of the center of the selected element relative to the upper-left corner of the element itselfx
{int
} - X-coordinate of the selected elements center relative to the upper-left corner of the element itselfy
{int
} - Y-coordinate of the selected elements center relative to the upper-left corner of the element itself
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elements
-
selector
-
[callBack]
Selects DOM elements, triggering each selected element on the supplied callback function
Parameters:
Returns:
The chain object
Example:
// Determines all element with the "title" class and prints the
// text content of these elements to the console, one-by-one
driver.elements('.title', function (element) {
console.log(element.getText());
});
Callback function
function (
element
,index
)
Scope
{
Chain
}
Parameters
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementSendKeys
-
selector
-
keys
-
[callBack]
Types complete strings or key-strokes into the selected element
Parameters:
Returns:
The chain object
Callback function
function (
element
,index
)
Scope
{
Chain
}
Parameters
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementSize
-
selector
-
[callBack]
Determines the size of the selected elements
Parameters:
Returns:
The chain object
Callback function
function (
size
,element
,index
)
Scope
{
Chain
}
Parameters
size
{object
} - Size of the selected elementwidth
{int
} - Width of the selected elementheight
{int
} - Height of the selected element
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementSubmit
-
selector
-
[callBack]
Submits the selected form elements
Note This should be usually only one form element. It doesn't make sense to apply this to any other element type.
Parameters:
Returns:
The chain object
Callback function
function (
element
,index
)
Scope
{
Chain
}
Parameters
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementTagName
-
selector
-
[callBack]
Gets the name of the tag for each selected element
Parameters:
Returns:
The chain object
Callback function
function (
tagName
,element
,index
)
Scope
{
Chain
}
Parameters
tagName
{string
} - Tag-name of the selected elementelement
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementTap
-
selector
-
[callBack]
Taps on the selected elements
Parameters:
Returns:
The chain object
Callback function
function (
element
,index
)
Scope
{
Chain
}
Parameters
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementText
-
selector
-
[callBack]
Gets the text content of the selected elements
Parameters:
Returns:
The chain object
Example:
// Retrieves the contents of an article synopsis
driver.elementText('.synopsis', function (text) {
console.log(text);
});
Callback function
function (
text
,element
,index
)
Scope
{
Chain
}
Parameters
text
{string
} - Text content of selected elementelement
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementTouch
-
selector
-
[callBack]
Triggers a touch-event on the selected elements
Parameters:
Returns:
The chain object
Callback function
function (
element
,index
)
Scope
{
Chain
}
Parameters
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementTouchAt
-
selector
-
xOffset
-
yOffset
-
[callBack]
Triggers a touch-event on the selected element relative to the upper-left corner of the elements
Parameters:
Returns:
The chain object
Callback function
function (
element
,index
)
Scope
{
Chain
}
Parameters
element
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
elementValue
-
selector
-
[callBack]
Determines the contents of the value
attribute on each selected element
Note
This will only work on elements that have a value
attribute.
Parameters:
Returns:
The chain object
Callback function
function (
value
,element
,index
)
Scope
{
Chain
}
Parameters
value
{string
} - Value of the "value" attribute of the selected elementelement
{Element
} - Selected elementindex
{int
} - Zero-based index of the selected element
end
()
Driver
Completes the session by finishing up comparison tasks and closing the browser window
Note You cannot chain after this function call anymore, and the driver will be closed so that there is no way anymore to access the browser through the same session. To get access again to the browser, you need to create a whole new Taxi instance.
Returns:
forward
-
[callBack]
Goes forward in the document history, equivalent to a user pressing the forward button within the browser
Parameters:
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
hover
-
x
-
y
-
[callBack]
Hovers the mouse over the active document at the specified absolute coordinates
Parameters:
-
x
IntAbsolute x-coordinate to hover above
-
y
IntAbsolute y-coordinate to hover above
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
location
-
[callBack]
Determines the absolute location of the active window
Parameters:
-
[callBack]
Function optionalCallback function that will be triggered with the location of the window
Returns:
The chain object
Callback function
function (
location
,activeWindow
)
Scope
{
Chain
}
Parameters
location
{object
} - Absolute location of the selected elementx
{int
} - Absolute x-coordinate of the selected elementy
{int
} - Absolute y-coordinate of the selected element
activeWindow
{ActiveWindow
} - Active browser document/window
maximize
-
[callBack]
Expands the active window to its maximum size
Parameters:
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
refresh
-
[callBack]
Refreshes the current document as if the user pressed the refresh button within the browser
Parameters:
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
relocate
-
x
-
y
-
[callBack]
Determines the absolute location of the active window
Parameters:
-
x
IntAbsolute x-coordinate of the next window location
-
y
IntAbsolute y-coordinate of the next window location
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
resize
-
width
-
height
-
[callBack]
Re-sizes the active window
Parameters:
-
width
IntWidth of the window
-
height
IntHeight of the window
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
scrollBy
-
xOffset
-
yOffset
-
[callBack]
Scrolls the currently active document to a specific offset relative to the current scroll location
Parameters:
-
xOffset
IntX-offset to scroll to relative to the current scroll position
-
yOffset
IntY-offset to scroll to relative to the current scroll position
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
scrollLocation
-
[callBack]
Determines the scroll location coordinates within the currently active document
Parameters:
-
[callBack]
Function optionalCallback function that will be triggered with the scroll-location of the active window
Returns:
The chain object
Callback function
function (
coordinates
,activeWindow
)
Scope
{
Chain
}
Parameters
coordinates
{object
} - Absolute coordinates of the view-port scroll locationx
{int
} - Absolute x-coordinate of the view-port scroll locationy
{int
} - Absolute y-coordinate of the view-port scroll location
activeWindow
{ActiveWindow
} - Active browser document/window
scrollTo
-
x
-
y
-
[callBack]
Scrolls to an absolute scroll location within the currently active document
Parameters:
-
x
IntAbsolute x-coordinate to scroll to
-
y
IntAbsolute y-coordinate to scroll to
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
sendKeys
-
keys
-
[callBack]
Types complete strings or key-strokes into the active window, effectively sending key-strokes to the focused element
Parameters:
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
size
-
[callBack]
Determines the size of the active window
Parameters:
-
[callBack]
Function optionalCallback function that will be triggered with the size of the window
Returns:
The chain object
Callback function
function (
size
,activeWindow
)
Scope
{
Chain
}
Parameters
size
{object
} - Size of the selected elementwidth
{int
} - Width of the selected elementheight
{int
} - Height of the selected element
activeWindow
{ActiveWindow
} - Active browser document/window
sleep
-
ms
-
[callBack]
Puts Taxi to sleep for a specific amount of time
Parameters:
-
ms
IntTime in milliseconds to wait
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
source
-
[callBack]
Determines the source-code of the currently active document
Parameters:
-
[callBack]
Function optionalCallback function that will be triggered with the source-code of the document
Returns:
The chain object
Callback function
function (
source
,activeWindow
)
Scope
{
Chain
}
Parameters
source
{string
} - Source-code of the active browser documentactiveWindow
{ActiveWindow
} - Active browser document/window
title
-
[callBack]
Determines the title of the currently active document
Parameters:
-
[callBack]
Function optionalCallback function that will be triggered with the title of the document
Returns:
The chain object
Callback function
function (
title
,activeWindow
)
Scope
{
Chain
}
Parameters
title
{string
} - Title of the active browser documentactiveWindow
{ActiveWindow
} - Active browser document/window
url
-
[callBack]
Determines the current URL of the active document
Parameters:
-
[callBack]
Function optionalCallback function that will be called with the URL of the document
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
url
{string
} - URL of the active documentactiveWindow
{ActiveWindow
} - Active browser document/window
waitForElementDisplay
-
selector
-
[timeOut=10000]
-
[abortOnFailure=true]
-
[callBack]
Waits for a specific amount of time that an element will be shown
Parameters:
-
selector
StringCSS selector of DOM elements
-
[timeOut=10000]
Int optionalMax. time-out in waiting on the element
-
[abortOnFailure=true]
Boolean optionalShould an exception be thrown when time-out is reached?
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
waitForElementNotDisplayed
-
selector
-
[timeOut=10000]
-
[abortOnFailure=true]
-
[callBack]
Waits for a specific amount of time that an element will be hidden
Parameters:
-
selector
StringCSS selector of DOM elements
-
[timeOut=10000]
Int optionalMax. time-out in waiting on the element
-
[abortOnFailure=true]
Boolean optionalShould an exception be thrown when time-out is reached?
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
waitForElementNotPresent
-
selector
-
[timeOut=10000]
-
[abortOnFailure=true]
-
[callBack]
Waits for a specific amount of time that an element disappears from the DOM
Parameters:
-
selector
StringCSS selector of DOM elements
-
[timeOut=10000]
Int optionalMax. time-out in waiting on the element
-
[abortOnFailure=true]
Boolean optionalShould an exception be thrown when time-out is reached?
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
waitForElementPresent
-
selector
-
[timeOut=10000]
-
[abortOnFailure=true]
-
[callBack]
Waits for a specific amount of time that an element appears in the DOM
Parameters:
-
selector
StringCSS selector of DOM elements
-
[timeOut=10000]
Int optionalMax. time-out in waiting on the element
-
[abortOnFailure=true]
Boolean optionalShould an exception be thrown when time-out is reached?
-
[callBack]
Function optionalCallback function that will be triggered when the action completes
Returns:
The chain object
Callback function
function (
activeWindow
)
Scope
{
Chain
}
Parameters
activeWindow
{ActiveWindow
} - Active browser document/window
windows
-
[callBack]
Determines a list of available windows/documents within the same browser session
Parameters:
-
[callBack]
Function optionalCallback function that will be triggered with a list of available windows
Returns:
The chain object
Callback function
function (
windows
,browser
)
Scope
{
Chain
}
Parameters
windows
{WindowHandler[]
} - A list of window objects that are open in the browserbrowser
{Browser
} - The browser session