Selector API methods
hasClass
Checks if an element has a specific class.
Parameter | Type | Description |
---|---|---|
className | string | Class name. |
Return value
Promise<boolean>
Returns true
if element has the specified class name.
hasAttribute
Checks if an element has a specific attribute.
Parameter | Type | Description |
---|---|---|
attributeName | string | Attribute name. |
Return value
Promise<boolean>
Returns true
if element has the specified attribute name.
getAttribute
Gets the attribute value.
Parameter | Type | Description |
---|---|---|
attributeName | string | Attribute name. |
Return value
Promise<string>
Returns the actual value of the specified attribute.
getStyleProperty
Parameter | Type | Description |
---|---|---|
propertyName | string | Property name. |
Return value
Promise<string>
Returns the actual value of the specified style property.
getBoundingClientRectProperty
Parameter | Type | Description |
---|---|---|
propertyName | string | Property name. |
Return value
Promise<number>
Returns the actual value of the specified property about the element size or position relative to viewport.
nth
Matches an element based on their position among a group of siblings. The group of siblings is composed of any type of element.
Parameter | Type | Description |
---|---|---|
index | number | Element position among group of siblings. |
Return value
Selector
Returns (depending on the index value) one of the selector matching the initial selector.
withText
Allows to look for an element that contains the specified text.
Parameter | Type | Description |
---|---|---|
value | string / RegExp | Text value to search for. |
Return value
Selector
Returns the selector of the element.
withExactText
Allows to look for an element that contains the specified exact text.
Parameter | Type | Description |
---|---|---|
value | string | Text value to search for. |
Return value
Selector
Returns the selector of the element.
withAttribute
Allows to look for an element that contains the specified attribute.
Parameter | Type | Description |
---|---|---|
attrName | string / RegExp | Attribute name to search for. |
attrValue | string / RegExp | Attribute value to search for. |
Return value
Selector
Returns the selector of the element.
filter
Allows to look for an element that contains the specified selector.
Parameter | Type | Description |
---|---|---|
cssSelector / xPathSelector / filterFn ,dependencies? | string / string / (node: Element, idx?: number, originNode?: Element) => boolean ,{[key: string]: any;} | Selector matching the element. |
filter Return value
Selector
Returns the selector of the element.
filterVisible
Allows to look for a visible element matching a selector.
Return value
Selector
Returns the selector of the element.
filterHidden
Allows to look for an hidden element matching a selector.
Return value
Selector
Returns the selector of the element.
find
Allows to look for element matching a selector CSS selector.
Parameter | Type | Description |
---|---|---|
cssSelector / xPathSelector / filterFn ,dependencies? | string / string / (node: Element, idx?: number, originNode?: Element) => boolean ,{[key: string]: any;} | Selector matching the element. |
find Return value
Selector
Returns the selector of the element.
parent
Allows to look for a parent selector.
Parameter | Type | Description |
---|---|---|
index / cssSelector / xPathSelector / filterFn ,dependencies? | number / string / string / (node: Element, idx?: number, originNode?: Element) => boolean ,{[key: string]: any;} | Selector or index matching the element. |
parent Return value
Selector
Returns the selector of the element.
child
Allows to look for a child selector.
Parameter | Type | Description |
---|---|---|
index / cssSelector / xPathSelector / filterFn ,dependencies? | number / string / string / (node: Element, idx?: number, originNode?: Element) => boolean ,{[key: string]: any;} | Selector or index matching the element. |
child Return value
Selector
Returns the selector of the element.
sibling
Allows to look for a sibling selector.
Parameter | Type | Description |
---|---|---|
index / cssSelector / xPathSelector / filterFn ,dependencies? | number / string / string / (node: Element, idx?: number, originNode?: Element) => boolean ,{[key: string]: any;} | Selector or index matching the element. |
sibling Return value
Selector
Returns the selector of the element.
nextSibling
Allows to look for a among the next sibling selector.
Parameter | Type | Description |
---|---|---|
index / cssSelector / xPathSelector / filterFn ,dependencies? | number / string / string / (node: Element, idx?: number, originNode?: Element) => boolean ,{[key: string]: any;} | Selector or index matching the element. |
nextSibling Return value
Selector
Returns the selector of the element.
prevSibling
Allows to look for a among the next sibling selector.
Parameter | Type | Description |
---|---|---|
index / cssSelector / xPathSelector / filterFn ,dependencies? | number / string / string / function ,{[key: string]: any;} | Selector or index matching the element. |
prevSibling Return value
Selector
Returns the selector of the element.
all
Allows to gather all occurrences of a Selector inside an array.
Return value
Selector[]
Returns an array of `Selector.
clone
Allows to clone a specific selector.
Parameter | Type | Description |
---|---|---|
cloneActions | boolean / undefined · | Enable clone actions. |
Return value
Selector
Returns a duplicate of the selector on which the method was called .
with
The with
statement extends the scope chain for a statement.
Parameter | Type | Description |
---|---|---|
options | object | Selector options. |
options
Selector options
Parameter | Type | Description |
---|---|---|
interval | number | Time interval between retries in milliseconds. |
timeout | number | Timeout of the method. |
retries | number | Number of retries. |
backoff | FIXED / EXPONENTIAL / LINEAR | Value used to determine the wait time between successive retries. |
maxBackOff | number | Maximum value of backoff. |
errorMessage | string | Error message. |
overrideErrorMessage | string | Override the Test Maker error message. |
retryMessage | string | Retry message. |
Return value
Selector
Returns the selector of the element.
expect
Parameter | Type | Description |
---|---|---|
options | object | Assertion options. |
options
Assertion options
Parameter | Type | Description |
---|---|---|
interval | number | Time interval between retries in milliseconds. |
timeout | number | Timeout of the method. |
retries | number | Number of retries. |
backoff | FIXED / EXPONENTIAL / LINEAR / ((attempt: number, delay: number) => number) | Value used to determine the wait time between successive retries . |
maxBackOff | number | Maximum value of backoff. |
errorMessage | string | Error message. |
overrideErrorMessage | string | Override the Test Maker error message. |
retryMessage | string | Retry message. |
Return value
number
Value used to determine the wait time between successive retries.
waitForToExist
Description
Waits for the Selector
to exist in the DOM.
Basic usage
import { Feature, Selector } from 'test-maker';
Feature(`Example Feature`)
.Scenario(`Example Scenario`)
.Given(`We Visit google search page`, async (I) => {
// Wait for the body to exist with a custom timeout of 5 seconds and a polling interval of 300 milliseconds
await Selector("body", { timeout: 5000, interval: 300 }).waitForToExist();
});
waitForToNotExist
Description
Waits for the Selector
to not exist in the DOM.
Basic usage
import { Feature, Selector } from 'test-maker';
Feature(`Example Feature`)
.Scenario(`Example Scenario`)
.Given(`We Visit google search page`, async (I) => {
// Wait for the body to not exist with a custom timeout of 5 seconds and a polling interval of 300 milliseconds
await Selector("body", { timeout: 5000, interval: 300 }).waitForToNotExist();
});
waitForToBeVisible
Description
Waits for the Selector
to become visible.
Basic usage
import { Feature, Selector } from 'test-maker';
Feature(`Example Feature`)
.Scenario(`Example Scenario`)
.Given(`We Visit google search page`, async (I) => {
// Wait for the body to become visible with a custom timeout of 5 seconds and a polling interval of 300 milliseconds
await Selector("body", { timeout: 5000, interval: 300 }).waitForToBeVisible();
});
waitForToBeInvisible
Description
Waits for the Selector
to become invisible.
Basic usage
import { Feature, Selector } from 'test-maker';
Feature(`Example Feature`)
.Scenario(`Example Scenario`)
.Given(`We Visit google search page`, async (I) => {
// Wait for the body to become invisible with a custom timeout of 5 seconds and a polling interval of 300 milliseconds
await Selector("body", { timeout: 5000, interval: 300 }).waitForToBeInvisible();
});