Class: Playwright::PageAssertions
- Inherits:
-
PlaywrightApi
- Object
- PlaywrightApi
- Playwright::PageAssertions
- Defined in:
- lib/playwright_api/page_assertions.rb
Overview
The ‘PageAssertions` class provides assertion methods that can be used to make assertions about the `Page` state in the tests.
“‘python sync import re from playwright.sync_api import Page, expect
def test_navigates_to_login_page(page: Page) -> None:
# ..
page.get_by_text("Sign in").click()
expect(page).to_have_url(re.compile(r".*/login"))
“‘
Instance Method Summary collapse
-
#not_to_have_title(titleOrRegExp, timeout: nil) ⇒ Object
The opposite of [‘method: PageAssertions.toHaveTitle`].
-
#not_to_have_url(urlOrRegExp, ignoreCase: nil, timeout: nil) ⇒ Object
The opposite of [‘method: PageAssertions.toHaveURL`].
-
#not_to_match_aria_snapshot(expected, timeout: nil) ⇒ Object
The opposite of [‘method: PageAssertions.toMatchAriaSnapshot`].
-
#to_have_title(titleOrRegExp, timeout: nil) ⇒ Object
Ensures the page has the given title.
-
#to_have_url(urlOrRegExp, ignoreCase: nil, timeout: nil) ⇒ Object
Ensures the page is navigated to the given URL.
-
#to_match_aria_snapshot(expected, timeout: nil) ⇒ Object
Asserts that the page body matches the given [accessibility snapshot](../aria-snapshots.md).
Methods inherited from PlaywrightApi
Constructor Details
This class inherits a constructor from Playwright::PlaywrightApi
Instance Method Details
#not_to_have_title(titleOrRegExp, timeout: nil) ⇒ Object
The opposite of [‘method: PageAssertions.toHaveTitle`].
18 19 20 |
# File 'lib/playwright_api/page_assertions.rb', line 18 def not_to_have_title(titleOrRegExp, timeout: nil) wrap_impl(@impl.not_to_have_title(unwrap_impl(titleOrRegExp), timeout: unwrap_impl(timeout))) end |
#not_to_have_url(urlOrRegExp, ignoreCase: nil, timeout: nil) ⇒ Object
The opposite of [‘method: PageAssertions.toHaveURL`].
24 25 26 |
# File 'lib/playwright_api/page_assertions.rb', line 24 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 |
#not_to_match_aria_snapshot(expected, timeout: nil) ⇒ Object
The opposite of [‘method: PageAssertions.toMatchAriaSnapshot`].
46 47 48 |
# File 'lib/playwright_api/page_assertions.rb', line 46 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 |
#to_have_title(titleOrRegExp, timeout: nil) ⇒ Object
Ensures the page has the given title.
Usage
“‘python sync import re from playwright.sync_api import expect
# … expect(page).to_have_title(re.compile(r“.*checkout”)) “‘
62 63 64 |
# File 'lib/playwright_api/page_assertions.rb', line 62 def to_have_title(titleOrRegExp, timeout: nil) wrap_impl(@impl.to_have_title(unwrap_impl(titleOrRegExp), timeout: unwrap_impl(timeout))) end |
#to_have_url(urlOrRegExp, ignoreCase: nil, timeout: nil) ⇒ Object
Ensures the page is navigated to the given URL.
Usage
“‘python sync import re from playwright.sync_api import expect
# … expect(page).to_have_url(re.compile(“.*checkout”)) “‘
78 79 80 |
# File 'lib/playwright_api/page_assertions.rb', line 78 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 |
#to_match_aria_snapshot(expected, timeout: nil) ⇒ Object
Asserts that the page body matches the given [accessibility snapshot](../aria-snapshots.md).
Usage
“‘python sync page.goto(“demo.playwright.dev/todomvc/”) expect(page).to_match_aria_snapshot(”’
- heading "todos"
- textbox "What needs to be done?"
”‘) “`
40 41 42 |
# File 'lib/playwright_api/page_assertions.rb', line 40 def to_match_aria_snapshot(expected, timeout: nil) wrap_impl(@impl.to_match_aria_snapshot(unwrap_impl(expected), timeout: unwrap_impl(timeout))) end |