2021-10-21 17:44:17 -07:00
# class: PageAssertions
* langs: java
2021-10-22 16:56:58 -07:00
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` ].
2021-10-21 17:44:17 -07:00
## method: PageAssertions.hasTitle
2021-10-22 16:56:58 -07:00
Ensures the page has the given title.
2021-10-21 17:44:17 -07:00
```java
assertThat(page).hasTitle("Playwright");
```
### param: PageAssertions.hasTitle.titleOrRegExp
- `titleOrRegExp` < [string]|[RegExp]>
Expected title or RegExp.
2021-10-22 16:56:58 -07:00
### option: PageAssertions.hasTitle.timeout = %%-assertions-timeout-%%
2021-10-21 17:44:17 -07:00
## method: PageAssertions.hasURL
Ensures the page is navigated to the given URL.
```java
assertThat(page).hasURL('.com');
```
### param: PageAssertions.hasURL.urlOrRegExp
- `urlOrRegExp` < [string]|[RegExp]>
Expected substring or RegExp.
2021-10-22 16:56:58 -07:00
### option: PageAssertions.hasURL.timeout = %%-assertions-timeout-%%
2021-10-21 17:44:17 -07:00
## 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"` :
```java
assertThat(page).not().hasURL('error');
```