Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs(java): assertion examples (#10194)

Yury Semikhatsky031ceb3553c1
diff --git a/docs/src/api/class-locatorassertions.md b/docs/src/api/class-locatorassertions.md
index eda9a2f39f..1d0aad31bc 100644
--- a/docs/src/api/class-locatorassertions.md
+++ b/docs/src/api/class-locatorassertions.md
@@ -1,7 +1,22 @@
# class: LocatorAssertions
* langs: java
-The [LocatorAssertions] class provides assertion methods that can be used to make assertions about the [Locator] state in the tests. A new instance of [LocatorAssertions] is created by calling [`method: PlaywrightAssertions.assertThatLocator`].
+The [LocatorAssertions] class provides assertion methods that can be used to make assertions about the [Locator] state in the tests. A new instance of [LocatorAssertions] is created by calling [`method: PlaywrightAssertions.assertThatLocator`]:
+
+```java
+...
+import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
+
+public class TestLocator {
+ ...
+ @Test
+ void statusBecomesSubmitted() {
+ ...
+ page.click("#submit-button");
+ assertThat(page.locator(".status")).hasText("Submitted");
+ }
+}
+```
## method: LocatorAssertions.containsText
diff --git a/docs/src/api/class-pageassertions.md b/docs/src/api/class-pageassertions.md
index 6a56183034..5b4a6007af 100644
--- a/docs/src/api/class-pageassertions.md
+++ b/docs/src/api/class-pageassertions.md
@@ -1,7 +1,22 @@
# class: PageAssertions
* langs: java
-The [PageAssertions] class provides assertion methods that can be used to make assertions about the [Page] state in the tests. A new instance of [LocatorAssertions] is created by calling [`method: PlaywrightAssertions.assertThatPage`].
+The [PageAssertions] class provides assertion methods that can be used to make assertions about the [Page] state in the tests. A new instance of [LocatorAssertions] is created by calling [`method: PlaywrightAssertions.assertThatPage`]:
+
+```java
+...
+import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
+
+public class TestPage {
+ ...
+ @Test
+ void navigatesToLoginPage() {
+ ...
+ page.click("#login");
+ assertThat(page).hasURL(Pattern.compile(".*/login"));
+ }
+}
+```
## method: PageAssertions.hasTitle
diff --git a/docs/src/api/class-playwrightassertions.md b/docs/src/api/class-playwrightassertions.md
index 214bd42d94..6c6162d193 100644
--- a/docs/src/api/class-playwrightassertions.md
+++ b/docs/src/api/class-playwrightassertions.md
@@ -32,7 +32,7 @@ To use Playwright assertions add the following dependency into the `pom.xml` of
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>assertions</artifactId>
- <version>1.16.0</version>
+ <version>1.17.0</version>
</dependency>
```