Assertions and Test subjects

Suitest lets you inspect different objects inside the application and provides flexible ways to create assertions about the object's properties. This is done with the use of different test subjects combined with chain modifiers.


List of assertions and test subjects:


application

application() defines an Application subject. Needs to be combined with hasExited.

/**
 * @returns {ChainablePromise.<void|boolean>}
 */
async function application() {}

// Check if application has exited
const ApplicationHasExited = await suitest.application().hasExited();

cookie() defines a Cookie subject.

/**
 * @param {string} name - cookie name
 * @returns {ChainablePromise.<void|boolean|string>}
 */
async function cookie(name) {}

const cookieValue = await suitest.cookie('cookieName');

element

element() defines a View element subject.

The element apiId can be found in the element repository.

/**
 * @param {string} apiId - Api ID of the element from Element Repository
 */
async function element(apiId) {}

/**
 * @param {string} [css] - CSS selector, e.g. ”#elementID > .child-element”
 * @param {string} [xpath] - XPath selector. Note that not all platforms support XPath
 * @param {number} [index] - which element should be taken when more then one match found
 * @param {string} [attributes] - select element by it's attributes
 * @param {string} [text] - select element by inner text
 * @param {string} [position] - select element by it's position
 * @param {string} [size] - select element by it's size
 * @param {string} [color] - select element by color
 * @param {boolean} [video] - select video element
 * @returns {ChainablePromise.<void|boolean|Object>}
 */
async function element({css, xpath, index, attributes, text, position, size, color, video}) {}

// Look up element by API ID in Element Repository
const elementProps = await suitest.element('ElementApiID');

// Look up element by complex selector. All keys are optional, but at least one must exist
const elementProps = await suitest.element({
    css: 'css selector',
    xpath: 'xpath selector',
    index: 1,
});

jsExpression

jsExpression() defines a JavaScript expression subject.

/**
 * @param {string|Function} expression - source to be executed on device
 * @returns {ChainablePromise.<void|boolean|string>}
 */
async function jsExpression(expression) {}

// Parameter passed as string
const evaluationResult = await suitest.jsExpression('1+2');

// Parameter passed as JS function. Executed on device in a global scope
const evaluationResult = await suitest.jsExpression(function () {return 1 + 2;});

location

location() defines a Current location subject.

/**
 * @returns {ChainablePromise.<void|boolean|string>}
 */
async function location() {}

const currentLocation = await suitest.location();

networkRequest

networkRequest() defines a Network request subject. Used in conjunction with .wasMade() and .willBeMade() chain modifiers.

/**
 * @returns {ChainablePromise.<void|boolean>}
 */
async function networkRequest(target, req, res, countPrevious) {}

// Find POST to http://suite.st with response status 200 only in new logs
const requestWillBeMade = await suitest.networkRequest()
    .contains('http://file.suite.st')
    .requestMatches(suitest.NETWORK_PROP.METHOD, suitest.NETWORK_METHOD.POST)
    .responseMatches(suitest.NETWORK_PROP.STATUS, 200)
    .willBeMade();

position

position() defines the position subject, takes coordinates as x and y axis for position on subject.

/**
 * Define position subject
 * @param {number} x - horizontal position
 * @param {number} y - vertical position
 * @returns {ChainablePromise.<void|boolean>}
 */
async function position(x, y) {}

// Click on position
await suitest.position(100, 200)
    .click();

video

video() defines a Video subject.

/**
 * Look up video element
 * @returns {ChainablePromise.<void|boolean|Object>}
 */
async function video() {}

// Look up video element
const elementProps = await suitest.video();

await suitest.element({video: true}) // longer version of the above can use both depending on your preference

window

window() defines the current window subject, needs to be combined with chain methods and test operation browser commands.

// Current browser window
async function window() {}

//for example - refresh the current browser window
await suitest.window().refresh();