Skip to content

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

docs(api): add assertions API for java (#9660)

Yury Semikhatskye7b4c181c7dd
diff --git a/docs/src/api/class-pageassertions.md b/docs/src/api/class-pageassertions.md
new file mode 100644
index 0000000000..2fa418e366
--- /dev/null
+++ b/docs/src/api/class-pageassertions.md
@@ -0,0 +1,49 @@
+# class: PageAssertions
+* langs: java
+
+The [PageAssertions] class provides assertion methods that can be used to make assertions about the [Page] state in the tests.
+
+## method: PageAssertions.hasTitle
+
+Ensures the page has a given title.
+
+```java
+assertThat(page).hasTitle("Playwright");
+```
+
+### param: PageAssertions.hasTitle.titleOrRegExp
+- `titleOrRegExp` <[string]|[RegExp]>
+
+Expected title or RegExp.
+
+### option: PageAssertions.hasTitle.timeout
+- `timeout` <[float]>
+
+Time to retry assertion for.
+
+## method: PageAssertions.hasURL
+
+Ensures the page is navigated to the given URL.
+
+```java
+assertThat(page).hasURL('.com');
+```
+
+### param: PageAssertions.hasURL.urlOrRegExp
+- `urlOrRegExp` <[string]|[RegExp]>
+
+Expected substring or RegExp.
+
+### option: PageAssertions.hasURL.timeout
+- `timeout` <[float]>
+
+Time to retry the assertion for.
+
+## method: PageAssertions.not
+- returns: <[PageAssertions]>
+
+Makes the assertion check for the opposite condition. For example, this code tests that the page URL doesn't contain `"error"`:
+
+```java
+assertThat(page).not().hasURL('error');
+```
diff --git a/docs/src/api/class-playwrightassertions.md b/docs/src/api/class-playwrightassertions.md
new file mode 100644
index 0000000000..2f6b3af540
--- /dev/null
+++ b/docs/src/api/class-playwrightassertions.md
@@ -0,0 +1,32 @@
+# class: PlaywrightAssertions
+* langs: java
+
+The [PlaywrightAssertions] class provides convenience methods for creating assertions that will wait until the expected condition is met.
+
+Consider the following example:
+
+```java
+assertThat(page.locator('.status')).hasText('Submitted');
+```
+
+Playwright will be re-testing the node with the selector `.status` until fetched Node has the `"Submitted"`
+text. It will be re-fetching the node and checking it over and over, until the condition is met or until the timeout is
+reached. You can pass this timeout as an option.
+
+By default, the timeout for assertions is set to 5 seconds.
+
+## method: PlaywrightAssertions.assertThat
+* langs: java
+- returns: <[PageAssertions]>
+
+Creates a [PageAssertions] object for the given [Page].
+
+```java
+PlaywrightAssertions.assertThat(page).hasTitle("News");
+```
+
+### param: PlaywrightAssertions.assertThat.page
+- `page` <[Page]>
+
+[Page] object to use for assertions.
+