playwright-java-soft-assertions gives you the ability to use Playwright's built in web-first assertions with soft assertions.
<dependency>
<groupId>io.github.uchagani</groupId>
<artifactId>playwright-java-soft-assertions</artifactId>
<version>1.0.1</version>
</dependency>Using playwright-java-soft-assertions is similar to other soft assertion implementations:
- Create an instance of the
SoftAssertionsobject - Use the soft assertions object to make calls to Playwright's assertions
- Call the
assertAll()method when you're done.
importio.github.uchagani.playwright.assertions.SoftAssertions;
publicclassFooTest {
@Testpublicvoidtest() {
LocatorsomeButton = page.locator("#some-id");
LocatorsomeLabel = page.locator(".my-label");
SoftAssertionssoftly = SoftAssertions.create();
softly.assertThat(someButton).isEnabled();
softly.assertThat(someLabel).hasText("foo");
softly.assertAll();
}
}All Playwright assertions are supported by playwright-java-soft-assertions including Page, Locator, and APIResponse.