Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
docs(java): correctly parse time (#31420)
Yury Semikhatsky865f0d822138
diff --git a/docs/src/api/class-clock.md b/docs/src/api/class-clock.mdindex 1a87cdffa0..6f70e72a02 100644--- a/docs/src/api/class-clock.md+++ b/docs/src/api/class-clock.md@@ -136,7 +136,8 @@ page.clock.pause_at("2020-02-02")``````java-page.clock().pauseAt(Instant.parse("2020-02-02"));+SimpleDateFormat format = new SimpleDateFormat("yyy-MM-dd");+page.clock().pauseAt(format.parse("2020-02-02"));page.clock().pauseAt("2020-02-02");```@@ -182,8 +183,8 @@ page.clock.set_fixed_time("2020-02-02")``````java-page.clock().setFixedTime(Instant.now());-page.clock().setFixedTime(Instant.parse("2020-02-02"));+page.clock().setFixedTime(new Date());+page.clock().setFixedTime(new SimpleDateFormat("yyy-MM-dd").parse("2020-02-02"));page.clock().setFixedTime("2020-02-02");```@@ -225,8 +226,8 @@ page.clock.set_system_time("2020-02-02")``````java-page.clock().setSystemTime(Instant.now());-page.clock().setSystemTime(Instant.parse("2020-02-02"));+page.clock().setSystemTime(new Date());+page.clock().setSystemTime(new SimpleDateFormat("yyy-MM-dd").parse("2020-02-02"));page.clock().setSystemTime("2020-02-02");```diff --git a/docs/src/clock.md b/docs/src/clock.mdindex b89dfd93d6..86d0ad9a10 100644--- a/docs/src/clock.md+++ b/docs/src/clock.md@@ -118,13 +118,14 @@ expect(page.get_by_test_id("current-time")).to_have_text("2/2/2024, 10:30:00 AM"```java// Initialize clock with some time before the test time and let the page load// naturally. `Date.now` will progress as the timers fire.-page.clock().install(new Clock.InstallOptions().setTime(Instant.parse("2024-02-02T08:00:00")));+SimpleDateFormat format = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss");+page.clock().install(new Clock.InstallOptions().setTime(format.parse("2024-02-02T08:00:00")));page.navigate("http://localhost:3333");Locator locator = page.getByTestId("current-time");// Pretend that the user closed the laptop lid and opened it again at 10am.// Pause the time once reached that point.-page.clock().pauseAt(Instant.parse("2024-02-02T10:00:00"));+page.clock().pauseAt(format.parse("2024-02-02T10:00:00"));// Assert the page state.assertThat(locator).hasText("2/2/2024, 10:00:00 AM");@@ -315,15 +316,16 @@ expect(locator).to_have_text("2/2/2024, 10:00:02 AM")``````java+SimpleDateFormat format = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss");// Initialize clock with a specific time, let the page load naturally.page.clock().install(new Clock.InstallOptions()- .setTime(Instant.parse("2024-02-02T08:00:00")));+ .setTime(format.parse("2024-02-02T08:00:00")));page.navigate("http://localhost:3333");Locator locator = page.getByTestId("current-time");// Pause the time flow, stop the timers, you now have manual control// over the page time.-page.clock().pauseAt(Instant.parse("2024-02-02T10:00:00"));+page.clock().pauseAt(format.parse("2024-02-02T10:00:00"));assertThat(locator).hasText("2/2/2024, 10:00:00 AM");// Tick through time manually, firing all timers in the process.