kotest-playwright-assertions provides Kotest-style assertions for Playwright.
Important
This library does not implement any assertions itself. It only wraps the Playwright assertions to provide a
Kotest-style API.
The assertions are generated based on the latest Playwright Java API. This means that if your project uses an older
version of Playwright, those newer assertions will fail with NoSuchMethodError in runtime.
Add to your build.gradle.kts:
dependencies {
testImplementation("io.orange-buffalo:kotest-playwright-assertions:$kotestPlaywrightAssertionsVersion")
}or to your pom.xml:
<dependency>
<groupId>io.orange-buffalo</groupId>
<artifactId>kotest-playwright-assertions</artifactId>
<version>${kotest-playwright-assertions.version}</version>
<scope>test</scope>
</dependency>The latest version can be taken from Maven Central.
import io.orangebuffalo.kotestplaywrightassertions
import com.microsoft.playwright.Page
...
val page: Page = ...
page.locator("#welcome").shouldHaveText("Welcome!")All assertions available in the latest version of Playwright are supported, with the following mapping:
has*->shouldHave*contains*->shouldContain*matches*->shouldMatch*is*->shouldBe*
All of them have also not variants, e.g.: shouldNotHave*, shouldNotContain*, etc.
- Kotlin 1.8+
- Kotest 5.x
- Playwright for Java 1.30+