मुख्य कॉन्टेंट में जाएँ

setSystemTime

Change the system time to the new now. Now can be a timestamp, date object, or not passed in which defaults to 0. No timers will be called, nor will the time left before they trigger change.

Usage
const clock = await browser.emulate('clock', { ... })
await clock.setSystemTime(date)
Parameters
NameTypeDetails
dateDate, numberThe new date to set the system time to.
Example
setSystemTime.js
const clock = await browser.emulate('clock', { now: new Date(2021, 3, 14) })
console.log(await browser.execute(() => new Date().getTime())) // returns 1618383600000

await clock.setSystemTime(new Date(2011, 3, 15))
console.log(await browser.execute(() => new Date().getTime())) // returns 1302850800000

Welcome! How can I help?

WebdriverIO AI Copilot