public interface PageAssertions
PageAssertions class provides assertion methods that can be used to make assertions about the Page state in the
tests. A new instance of LocatorAssertions is created by calling PlaywrightAssertions.assertThat():
{@code
...
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
public class TestPage {
...| Modifier and Type | Interface and Description |
|---|---|
static class |
PageAssertions.HasTitleOptions |
static class |
PageAssertions.HasURLOptions |
| Modifier and Type | Method and Description |
|---|---|
default void |
hasTitle(Pattern titleOrRegExp)
Ensures the page has the given title.
|
void |
hasTitle(Pattern titleOrRegExp,
PageAssertions.HasTitleOptions options)
Ensures the page has the given title.
|
default void |
hasTitle(String titleOrRegExp)
Ensures the page has the given title.
|
void |
hasTitle(String titleOrRegExp,
PageAssertions.HasTitleOptions options)
Ensures the page has the given title.
|
default void |
hasURL(Pattern urlOrRegExp)
Ensures the page is navigated to the given URL.
|
void |
hasURL(Pattern urlOrRegExp,
PageAssertions.HasURLOptions options)
Ensures the page is navigated to the given URL.
|
default void |
hasURL(String urlOrRegExp)
Ensures the page is navigated to the given URL.
|
void |
hasURL(String urlOrRegExp,
PageAssertions.HasURLOptions options)
Ensures the page is navigated to the given URL.
|
PageAssertions |
not()
Makes the assertion check for the opposite condition.
|
default void hasTitle(String titleOrRegExp)
assertThat(page).hasTitle("Playwright");
titleOrRegExp - Expected title or RegExp.void hasTitle(String titleOrRegExp, PageAssertions.HasTitleOptions options)
assertThat(page).hasTitle("Playwright");
titleOrRegExp - Expected title or RegExp.default void hasTitle(Pattern titleOrRegExp)
assertThat(page).hasTitle("Playwright");
titleOrRegExp - Expected title or RegExp.void hasTitle(Pattern titleOrRegExp, PageAssertions.HasTitleOptions options)
assertThat(page).hasTitle("Playwright");
titleOrRegExp - Expected title or RegExp.default void hasURL(String urlOrRegExp)
assertThat(page).hasURL(".com");
urlOrRegExp - Expected substring or RegExp.void hasURL(String urlOrRegExp, PageAssertions.HasURLOptions options)
assertThat(page).hasURL(".com");
urlOrRegExp - Expected substring or RegExp.default void hasURL(Pattern urlOrRegExp)
assertThat(page).hasURL(".com");
urlOrRegExp - Expected substring or RegExp.void hasURL(Pattern urlOrRegExp, PageAssertions.HasURLOptions options)
assertThat(page).hasURL(".com");
urlOrRegExp - Expected substring or RegExp.PageAssertions not()
"error":
assertThat(page).not().hasURL("error");
Copyright © 2021. All rights reserved.