UNPKG

webdriverio

Version:

Next-gen browser and mobile automation test framework for Node.js

28 lines (21 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = setTimeout; async function setTimeout(timeouts) { if (typeof timeouts !== 'object') { throw new Error('Parameter for "setTimeout" command needs to be an object'); } const timeoutValues = Object.values(timeouts); if (timeoutValues.length && timeoutValues.every(timeout => typeof timeout !== 'number' || timeout < 0 || timeout > Number.MAX_SAFE_INTEGER)) { throw new Error('Specified timeout values are not valid integer (see https://webdriver.io/docs/api/browser/setTimeout.html for documentation).'); } const implicit = timeouts.implicit; const pageLoad = timeouts['page load'] || timeouts.pageLoad; const script = timeouts.script; if (!this.isW3C) { return Promise.all([isFinite(implicit) && this.setTimeouts('implicit', implicit), isFinite(pageLoad) && this.setTimeouts('page load', pageLoad), isFinite(script) && this.setTimeouts('script', script)].filter(Boolean)); } return this.setTimeouts(implicit, pageLoad, script); }