Interface PageAssertions
- All Known Implementing Classes:
PageAssertionsImpl
public interface PageAssertions
The
PageAssertions class provides assertion methods that can be used to make assertions about the Page
state in the tests.
...
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
public class TestPage {
...
@Test
void navigatesToLoginPage() {
...
page.getByText("Sign in").click();
assertThat(page).hasURL(Pattern.compile(".*\/login"));
}
}
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic class -
Method Summary
Modifier and TypeMethodDescriptiondefault voidEnsures the page has the given title.voidhasTitle(String titleOrRegExp, PageAssertions.HasTitleOptions options) Ensures the page has the given title.default voidEnsures the page has the given title.voidhasTitle(Pattern titleOrRegExp, PageAssertions.HasTitleOptions options) Ensures the page has the given title.default voidEnsures the page is navigated to the given URL.voidhasURL(String urlOrRegExp, PageAssertions.HasURLOptions options) Ensures the page is navigated to the given URL.default voidEnsures the page is navigated to the given URL.voidhasURL(Pattern urlOrRegExp, PageAssertions.HasURLOptions options) Ensures the page is navigated to the given URL.not()Makes the assertion check for the opposite condition.
-
Method Details
-
not
PageAssertions not()Makes the assertion check for the opposite condition. For example, this code tests that the page URL doesn't contain"error":assertThat(page).not().hasURL("error");- Since:
- v1.20
-
hasTitle
Ensures the page has the given title.**Usage**
assertThat(page).hasTitle("Playwright");- Parameters:
titleOrRegExp- Expected title or RegExp.- Since:
- v1.20
-
hasTitle
Ensures the page has the given title.**Usage**
assertThat(page).hasTitle("Playwright");- Parameters:
titleOrRegExp- Expected title or RegExp.- Since:
- v1.20
-
hasTitle
Ensures the page has the given title.**Usage**
assertThat(page).hasTitle("Playwright");- Parameters:
titleOrRegExp- Expected title or RegExp.- Since:
- v1.20
-
hasTitle
Ensures the page has the given title.**Usage**
assertThat(page).hasTitle("Playwright");- Parameters:
titleOrRegExp- Expected title or RegExp.- Since:
- v1.20
-
hasURL
Ensures the page is navigated to the given URL.**Usage**
assertThat(page).hasURL(".com");- Parameters:
urlOrRegExp- Expected URL string or RegExp.- Since:
- v1.20
-
hasURL
Ensures the page is navigated to the given URL.**Usage**
assertThat(page).hasURL(".com");- Parameters:
urlOrRegExp- Expected URL string or RegExp.- Since:
- v1.20
-
hasURL
Ensures the page is navigated to the given URL.**Usage**
assertThat(page).hasURL(".com");- Parameters:
urlOrRegExp- Expected URL string or RegExp.- Since:
- v1.20
-
hasURL
Ensures the page is navigated to the given URL.**Usage**
assertThat(page).hasURL(".com");- Parameters:
urlOrRegExp- Expected URL string or RegExp.- Since:
- v1.20
-