docs: clarify how to import assertions (#9868)

This commit is contained in:
Yury Semikhatsky 2021-10-29 08:33:07 -07:00 committed by GitHub
parent ffbd6de665
commit 34e55007d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View file

@ -6,7 +6,18 @@ The [PlaywrightAssertions] class provides convenience methods for creating asser
Consider the following example:
```java
assertThat(page.locator('.status')).hasText('Submitted');
...
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
public class TestExample {
...
@Test
void statusBecomesSubmitted() {
...
page.click("#submit-button");
assertThat(page.locator(".status")).hasText("Submitted");
}
}
```
Playwright will be re-testing the node with the selector `.status` until fetched Node has the `"Submitted"`
@ -15,6 +26,16 @@ reached. You can pass this timeout as an option.
By default, the timeout for assertions is set to 5 seconds.
To use Playwright assertions add the following dependency into the `pom.xml` of your Maven project:
```xml
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>assertions</artifactId>
<version>1.16.0</version>
</dependency>
```
## method: PlaywrightAssertions.assertThatLocator
* langs: java
- alias-java: assertThat

View file

@ -59,7 +59,7 @@ public class Example {
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.9.0-alpha-0</version>
<version>1.16.0</version>
</dependency>
</dependencies>
<build>