class Playwright::PageAssertions
“‘
expect(page).to_have_url(re.compile(r“.*/login”))
page.get_by_text(“Sign in”).click()
# ..
def test_navigates_to_login_page(page: Page) -> None:
from playwright.sync_api import Page, expect
import re
“`python sync
The `PageAssertions` class provides assertion methods that can be used to make assertions about the `Page` state in the tests.
def not_to_have_title(titleOrRegExp, timeout: nil)
def not_to_have_title(titleOrRegExp, timeout: nil) wrap_impl(@impl.not_to_have_title(unwrap_impl(titleOrRegExp), timeout: unwrap_impl(timeout))) end
def not_to_have_url(urlOrRegExp, ignoreCase: nil, timeout: nil)
def not_to_have_url(urlOrRegExp, ignoreCase: nil, timeout: nil) wrap_impl(@impl.not_to_have_url(unwrap_impl(urlOrRegExp), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout))) end
def not_to_match_aria_snapshot(expected, timeout: nil)
def not_to_match_aria_snapshot(expected, timeout: nil) wrap_impl(@impl.not_to_match_aria_snapshot(unwrap_impl(expected), timeout: unwrap_impl(timeout))) end
def to_have_title(titleOrRegExp, timeout: nil)
expect(page).to_have_title(re.compile(r".*checkout"))
# ...
from playwright.sync_api import expect
import re
```python sync
**Usage**
Ensures the page has the given title.
def to_have_title(titleOrRegExp, timeout: nil) wrap_impl(@impl.to_have_title(unwrap_impl(titleOrRegExp), timeout: unwrap_impl(timeout))) end
def to_have_url(urlOrRegExp, ignoreCase: nil, timeout: nil)
expect(page).to_have_url(re.compile(".*checkout"))
# ...
from playwright.sync_api import expect
import re
```python sync
**Usage**
Ensures the page is navigated to the given URL.
def to_have_url(urlOrRegExp, ignoreCase: nil, timeout: nil) wrap_impl(@impl.to_have_url(unwrap_impl(urlOrRegExp), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout))) end
def to_match_aria_snapshot(expected, timeout: nil)
''')
- textbox "What needs to be done?"
- heading "todos"
expect(page).to_match_aria_snapshot('''
page.goto("https://demo.playwright.dev/todomvc/")
```python sync
**Usage**
Asserts that the page body matches the given [accessibility snapshot](../aria-snapshots.md).
def to_match_aria_snapshot(expected, timeout: nil) wrap_impl(@impl.to_match_aria_snapshot(unwrap_impl(expected), timeout: unwrap_impl(timeout))) end