MyGit

v1.45.0

microsoft/playwright

版本发布时间: 2024-06-25 06:26:44

microsoft/playwright最新发布版本:v1.46.1(2024-08-17 04:14:49)

Clock

Utilizing the new Clock API allows to manipulate and control time within tests to verify time-related behavior. This API covers many common scenarios, including:

// Initialize clock and let the page load naturally.
await page.clock.install({ time: new Date('2024-02-02T08:00:00') });
await page.goto('http://localhost:3333');

// Pretend that the user closed the laptop lid and opened it again at 10am,
// Pause the time once reached that point.
await page.clock.pauseAt(new Date('2024-02-02T10:00:00'));

// Assert the page state.
await expect(page.getByTestId('current-time')).toHaveText('2/2/2024, 10:00:00 AM');

// Close the laptop lid again and open it at 10:30am.
await page.clock.fastForward('30:00');
await expect(page.getByTestId('current-time')).toHaveText('2/2/2024, 10:30:00 AM');

See the clock guide for more details.

Test runner

Miscellaneous

Browser Versions

This version was also tested against the following stable channels:

相关地址:原始地址 下载(tar) 下载(zip)

查看:2024-06-25发行的版本