All files / webdriverio/src/commands/browser pause.js

100% Statements 2/2
100% Branches 1/1
100% Functions 2/2
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26                                              10x    
/**
 *
 * Pauses execution for a specific amount of time. It is recommended to not use this command to wait for an
 * element to show up. In order to avoid flaky test results it is better to use commands like
 * [`waitforExist`](/docs/api/element/waitForExist.html) or other waitFor* commands.
 *
 * <example>
    :pause.js
    it('should pause the execution', () => {
        const starttime = new Date().getTime()
        browser.pause(3000)
        const endtime = new Date().getTime()
        console.log(endtime - starttime) // outputs: 3000
    });
 * </example>
 *
 * @alias browser.pause
 * @param {Number} milliseconds time in ms
 * @type utility
 *
 */
 
export default function pause (milliseconds = 1000) {
    return new Promise((resolve) => setTimeout(resolve, milliseconds))
}