PageAssertions Class
The assertions of a page, as the web-first assertions of Playwright: each assertion runs the event loop of the page until it passes, and throws an ExpectationFailedException when it still fails after the timeout.
public sealed class PageAssertionsProperties
| Name | Description |
|---|---|
| Not | Gets the negated assertions (Expect(page).Not.ToHaveUrlAsync("http://localhost/sign-in")). |
Gets the negated assertions (Expect(page).Not.ToHaveUrlAsync("http://localhost/sign-in")).
public PageAssertions Not { get; }Property value
Methods
| Name | Description |
|---|---|
| ToHaveTitleAsync(string, TimeSpan?, CancellationToken) | Waits until the title of the active document is a text, once the white space of both texts is collapsed. |
| ToHaveTitleAsync(Regex, TimeSpan?, CancellationToken) | Waits until the title of the active document matches a regular expression. |
| ToHaveUrlAsync(string, TimeSpan?, CancellationToken) | Waits until the URL of the active document is a URL. |
| ToHaveUrlAsync(Regex, TimeSpan?, CancellationToken) | Waits until the URL of the active document matches a regular expression. |
ToHaveTitleAsync overloads
ToHaveTitleAsync(string, TimeSpan?, CancellationToken)
PageAssertions.csWaits until the title of the active document is a text, once the white space of both texts is collapsed.
public Task ToHaveTitleAsync(string title, TimeSpan? timeout = null, CancellationToken cancellationToken = default)Parameters
titlestring- The title.
timeoutTimeSpan?- The maximum time to wait, or null for
TestPage.DefaultTimeout. cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the assertion passes.
ToHaveTitleAsync(Regex, TimeSpan?, CancellationToken)
PageAssertions.csWaits until the title of the active document matches a regular expression.
public Task ToHaveTitleAsync(Regex title, TimeSpan? timeout = null, CancellationToken cancellationToken = default)Parameters
titleRegex- The regular expression.
timeoutTimeSpan?- The maximum time to wait, or null for
TestPage.DefaultTimeout. cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the assertion passes.
ToHaveUrlAsync overloads
ToHaveUrlAsync(string, TimeSpan?, CancellationToken)
PageAssertions.csWaits until the URL of the active document is a URL.
public Task ToHaveUrlAsync(string url, TimeSpan? timeout = null, CancellationToken cancellationToken = default)Parameters
urlstring- The URL, or a path relative to the URL of the document (
/profile). timeoutTimeSpan?- The maximum time to wait, or null for
TestPage.DefaultTimeout. cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the assertion passes.
ToHaveUrlAsync(Regex, TimeSpan?, CancellationToken)
PageAssertions.csWaits until the URL of the active document matches a regular expression.
public Task ToHaveUrlAsync(Regex url, TimeSpan? timeout = null, CancellationToken cancellationToken = default)Parameters
urlRegex- The regular expression.
timeoutTimeSpan?- The maximum time to wait, or null for
TestPage.DefaultTimeout. cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the assertion passes.