BrowserExpect
Namespace: E2E
public sealed class BrowserExpectPolling assertions for the Browser: its URL and its title. Like the
locator matchers, a passing one verifies the previous agent.act. A read is
bounded by the matcher’s own deadline, so a page that stops answering ends the
assertion at its timeout.
Inheritance: object
Properties
Section titled “Properties”public BrowserExpect Not { get; }Inverts the matcher. A negated matcher passes after its condition has been false for 1000 ms in a row.
Value: BrowserExpect
Methods
Section titled “Methods”ToHaveClassAsync(Locator, TextMatch, TimeSpan?, CancellationToken)
Section titled “ToHaveClassAsync(Locator, TextMatch, TimeSpan?, CancellationToken)”public Task ToHaveClassAsync(Locator target, TextMatch expected, TimeSpan? timeout = null, CancellationToken cancellationToken = default)Waits for the class attribute of <code class=“paramref”>target</code> to match <code class=“paramref”>expected</code>: a string is the whole class
list, whitespace-normalized, and a Regex is tested against it. An empty class="" is an empty class list; no
class attribute is not. A node that is not there yet keeps the matcher polling, and a node that never arrives fails it as an
assertion observing no node, where a read of the same locator would fail with NOT_FOUND. Several matches fail at once with
STRICT_MODE. Upstream’s expect(browser).toHaveClass.
Parameters
| Name | Type | Description |
|---|---|---|
target |
Locator | |
expected |
TextMatch | |
timeout |
TimeSpan? | |
cancellationToken |
CancellationToken |
Returns: Task
ToHaveTitleAsync(TextMatch, TimeSpan?, CancellationToken)
Section titled “ToHaveTitleAsync(TextMatch, TimeSpan?, CancellationToken)”public Task ToHaveTitleAsync(TextMatch expected, TimeSpan? timeout = null, CancellationToken cancellationToken = default)Waits for the title to equal <code class=“paramref”>expected</code> after whitespace normalization, or to match it.
Parameters
| Name | Type | Description |
|---|---|---|
expected |
TextMatch | |
timeout |
TimeSpan? | |
cancellationToken |
CancellationToken |
Returns: Task
ToHaveURLAsync(string, bool?, TimeSpan?, CancellationToken)
Section titled “ToHaveURLAsync(string, bool?, TimeSpan?, CancellationToken)”public Task ToHaveURLAsync(string expected, bool? ignoreCase = null, TimeSpan? timeout = null, CancellationToken cancellationToken = default)Waits for the URL to equal <code class=“paramref”>expected</code>, resolved against the base URL. Both sides are compared normalized (default port, trailing slash, dot segments, percent-encoding). <code class=“paramref”>ignoreCase</code> compares without case.
Parameters
| Name | Type | Description |
|---|---|---|
expected |
string | |
ignoreCase |
bool? | |
timeout |
TimeSpan? | |
cancellationToken |
CancellationToken |
Returns: Task
ToHaveURLAsync(Regex, bool?, TimeSpan?, CancellationToken)
Section titled “ToHaveURLAsync(Regex, bool?, TimeSpan?, CancellationToken)”public Task ToHaveURLAsync(Regex expected, bool? ignoreCase = null, TimeSpan? timeout = null, CancellationToken cancellationToken = default)Waits for the URL to match <code class=“paramref”>expected</code>, tested against the complete URL. <code class=“paramref”>ignoreCase</code> true adds IgnoreCase to the pattern, and false removes it.
Parameters
| Name | Type | Description |
|---|---|---|
expected |
Regex | |
ignoreCase |
bool? | |
timeout |
TimeSpan? | |
cancellationToken |
CancellationToken |
Returns: Task