mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
1.1 KiB
1.1 KiB
class: PageAssertions
- langs: java
The [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 [method: PlaywrightAssertions.assertThatPage
].
method: PageAssertions.hasTitle
Ensures the page has the given title.
assertThat(page).hasTitle("Playwright");
param: PageAssertions.hasTitle.titleOrRegExp
titleOrRegExp
<[string]|[RegExp]>
Expected title or RegExp.
option: PageAssertions.hasTitle.timeout = %%-assertions-timeout-%%
method: PageAssertions.hasURL
Ensures the page is navigated to the given URL.
assertThat(page).hasURL(".com");
param: PageAssertions.hasURL.urlOrRegExp
urlOrRegExp
<[string]|[RegExp]>
Expected substring or RegExp.
option: PageAssertions.hasURL.timeout = %%-assertions-timeout-%%
method: PageAssertions.not
- returns: <[PageAssertions]>
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");