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"));
}
}
Methods
hasTitle
Added in: v1.20Ensures the page has the given title.
Usage
assertThat(page).hasTitle("Playwright");
Arguments
-
titleOrRegExpString | Pattern Added in: v1.18#Expected title or RegExp.
-
optionsPageAssertions.HasTitleOptions(optional)
Returns
hasURL
Added in: v1.20Ensures the page is navigated to the given URL.
Usage
assertThat(page).hasURL(".com");
Arguments