Test operations

Test operations consist of user input, browser commands and other miscellaneous operations which are however still very useful. Using test operations you can simulate users input or interaction with the application as well as with the browser.


List of test operations:

User input -

  • click - click on element or position
  • moveTo - move mouse virtual mouse pointer to position or element
  • openApp - open application at homepage or relative URL
  • openUrl - open an absolute URL
  • press - execute a button press
  • sendText - send string or command to either a window or element

Browser command -

Other -


User input

Simulating user interaction with the application.

click

Mouse (left) clicks on element or position.

Learn more about click on in Suitest.

async function click() {}

// Click on element
await suitest.element('elementName')
    .click();

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

moveTo

Moves the (virtual) mouse pointer to either an element or position.

Learn more about move to in Suitest.

async function moveTo() {}

 // Move to element's centre
await suitest.element('elementName')
    .moveTo();

// Move to position given x and y coordinates
await suitest.position(100, 200)
    .moveTo();

openApp

Open app launches an applications either at the homepage or at a relative URL, it is mainly used at initial start of the application.

Learn more about Open app in Suitest.

/**
 * @param {string} [relativeUrl] - optional relative URL to navigate
 * @throws {AssertionError} - in case Suitest can't open application
 * @throws {SuitestError} - in case relativeUrl is of wrong type or empty string
 * @returns {ChainablePromise.<void>}
 */
async function openApp(relativeUrl) {}

// Open app at homepage
await suitest.openApp();

// Open app at relative URL
await suitest.openApp('/login');

openUrl

Open URL navigates to an absolute URL when called on an HTML-based platform.

Learn more about Open URL in Suitest.

/**
 * @param {string} absoluteUrl - absolute URL to navigate
 * @throws {AssertionError} - in case Suitest can't open URL
 * @throws {SuitestError} - in case command tries to run on non-HTML platform
 * @returns {Promise.<void|boolean>}
 */
async function openUrl(absoluteUrl) {}

// Open URL
await suitest.openUrl('https://suite.st/');

press

Executes a press of a button. Can be used in conjunction with .repeat, .interval and .until chain modifiers.

To see all Virtual Remote Control button options please refer to constants.

/**
 * @param {Symbol|Array<Symbol>} key - either a single key or array of keys
 * @throws {SuitestError} - e.g. platform does not support this key or device disconnected during execution
 * @returns {ChainablePromise.<void|boolean>}
 */
async function press(key) {}

// Press OK once
await suitest.press(suitest.VRC.OK);

// Press OK, UP once
await suitest.press([suitest.VRC.OK, suitest.VRC.UP]);

// Press OK exactly 10x every 10s
await suitest.press(suitest.VRC.OK)
    .repeat(10)
    .interval(10000);

// Press OK only if [condition]
if (await suitest.element('Element name').exists()) {
    await suitest.assert.press(suitest.VRC.OK);
}

// Press Ok until [condition]
await suitest.assert.press(suitest.VRC.OK).until(
    suitest.element('Element name').doesNot().exist()
).repeat(10).interval(1000);

sendText

Sends a string or keyboard button to a window or element.

Learn more about send text in Suitest. Also check the constants that can be used.

/**
 * @param {string} text - text to be send, including special keys in double square brackets
 * @returns {ChainablePromise.<void|boolean>}
 */
async function sendText(text) {}

// Send plain text to a window
await suitest.window()
    .sendText('Some string');

// Send text to an element with the `Alt` key pressed
await suitest.element('elementName')
    .sendText(`${suitest.KEY.ALT}complex string${suitest.KEY.NULL}`);

// Using constant
await suitest.element('elementName')
    .sendText(suitest.KEY.BACK_SPACE);

Browser command

Send specific commands to the browser.

Learn more about browser command in Suitest.

acceptModal

Accept the modal dialog (if one exists), with an option to send text if it's a prompt dialog.

Learn more about browser commands in Suitest.

// @param {string} [text] - text to be send to modal dialog
async function acceptModal(text) {}

// accept modal dialog
await suitest.window()
    .acceptModal();

// send text to modal dialog and accept it
await suitest.window()
    .acceptModal('Some text sent to the prompt');

dismissModal

Dismisses the modal dialog (if one exists) to proceed.

Learn more about browser commands in Suitest.

async function dismissModal() {}

await suitest.window()
    .dismissModal();

goBack

Returns to the previous page, used in conjunction with subject window.

async function goBack() {}

await suitest.window()
    .goBack();

goForward

Moves forward through the navigation history (only works after moving backwards), used in conjunction with subject window.

async function goForward() {}

await suitest.window()
    .goForward();

refresh

Refreshes the web page, used in conjunction with subject window.

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

await suitest.window()
    .refresh();

setSize

Sets the size, used in conjunction with subject window.

/**
 * @param {number} width - new width for the browser window, px
 * @param {number} height - new height for the browser window, px
 * @returns {ChainablePromise.<void|boolean>}
 */
async function setSize(width, height) {}

await suitest.window()
    .setSize(1024, 720);

Other

Other operations which you can use to adjust the behavior or set up aspects of your applications.

clearAppData

Clears applications data - cookies and local storage.

Learn more about clear app data in Suitest.

/**
 * @throws {SuitestError}
 * @returns {Promise.<void|boolean>}
 */
async function clearAppData() {}

await suitest.clearAppData();

executeCommand

Execute arbitrary JavaScript code on the device. Any HTML-based platforms are supported.

Learn more about Execute command in Suitest.

/**
 * @param {string|Function} command - a piece of JS to run on device
 * @throws {SyntaxError} - Error was thrown during evaluation on device
 * @throws {SuitestError} - e.g. platform does not support js
 * @returns {ChainablePromise.<void|boolean>}
 */
async function executeCommand(command) {}

await suitest.executeCommand("window.myApp.debugMode = 1");

pollUrl

Poll URL lets you continuously poll a particular URL, until you get an expected response.

Learn more about Poll URL in Suitest.

/**
 * @param {string} url
 * @param {string} response
 * @returns {ChainablePromise.<void|boolean>}
 */
async function pollURL(url, response) {}

// Poll URL and expect 200 repsonse
await suitest.pollURL('https://www.example.com/', '200');

sleep

Sleep pauses test execution for an amount of time in milliseconds.

Learn more about Sleep in Suitest.

/**
 * @param {number} ms - how long to sleep
 * @throws {SuitestError} - if something unexpected happened, e.g. device disconnected
 * @returns {ChainablePromise.<void|boolean>}
 */
async function sleep(ms) {}

// sleep for 3s
await suitest.sleep(3000);