Interface PlaywrightAssertions
-
public interface PlaywrightAssertions
Playwright gives you Web-First Assertions with convenience methods for creating assertions that will wait and retry until the expected condition is met.Consider the following example:
{@code ... import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat; public class TestExample { ...
-
-
Method Summary
Static Methods Modifier and Type Method Description static APIResponseAssertions
assertThat(APIResponse response)
Creates aAPIResponseAssertions
object for the givenAPIResponse
.static LocatorAssertions
assertThat(Locator locator)
Creates aLocatorAssertions
object for the givenLocator
.static PageAssertions
assertThat(Page page)
Creates aPageAssertions
object for the givenPage
.static void
setDefaultAssertionTimeout(double milliseconds)
Changes default timeout for Playwright assertions from 5 seconds to the specified value.
-
-
-
Method Detail
-
assertThat
static APIResponseAssertions assertThat(APIResponse response)
Creates aAPIResponseAssertions
object for the givenAPIResponse
.**Usage**
PlaywrightAssertions.assertThat(response).isOK();
- Parameters:
response
-APIResponse
object to use for assertions.- Since:
- v1.18
-
assertThat
static LocatorAssertions assertThat(Locator locator)
Creates aLocatorAssertions
object for the givenLocator
.**Usage**
PlaywrightAssertions.assertThat(locator).isVisible();
- Parameters:
locator
-Locator
object to use for assertions.- Since:
- v1.18
-
assertThat
static PageAssertions assertThat(Page page)
Creates aPageAssertions
object for the givenPage
.**Usage**
PlaywrightAssertions.assertThat(page).hasTitle("News");
- Parameters:
page
-Page
object to use for assertions.- Since:
- v1.18
-
setDefaultAssertionTimeout
static void setDefaultAssertionTimeout(double milliseconds)
Changes default timeout for Playwright assertions from 5 seconds to the specified value.**Usage**
PlaywrightAssertions.setDefaultAssertionTimeout(30_000);
- Parameters:
timeout
- Timeout in milliseconds.- Since:
- v1.25
-
-