Docs · API reference · Motus.Assertions

Expect Class#

The entry point to the assertion library: wraps a locator, page, or response in the assertions that apply to it.

public static class Expect

Inheritance System.Object → Expect

Remarks#

Assertions read as a sentence, and the ones reached through a locator or a page re-evaluate their condition until it holds or the timeout elapses, rather than testing once:

await Expect.That(page.GetByRole("alert")).ToBeVisibleAsync();
await Expect.That(page).ToHaveTitleAsync("Checkout");
await Expect.That(response).ToBeOkAsync();

Re-evaluating covers a value the page has not settled on yet, so an assertion after a navigation or an interaction is safe. It does not cover an element that is not there: a locator assertion needs its element present already and fails at once when the locator matches nothing, so wait for one that has still to render with ToBeAttachedAsync first. Insert Not to invert an assertion: Expect.That(locator).Not.ToBeVisibleAsync().

Methods#

That(ILocator) Method#

Begins an assertion about the element a locator resolves to.

public static Motus.Assertions.LocatorAssertions That(Motus.Abstractions.ILocator locator);

Parameters#

locator ILocator

The locator to assert against.

Returns#

LocatorAssertions

That(IPage) Method#

Begins an assertion about a page as a whole.

public static Motus.Assertions.PageAssertions That(Motus.Abstractions.IPage page);

Parameters#

page IPage

The page to assert against.

Returns#

PageAssertions

That(IResponse) Method#

Begins an assertion about a response the browser received.

public static Motus.Assertions.ResponseAssertions That(Motus.Abstractions.IResponse response);

Parameters#

response IResponse

The response to assert against.

Returns#

ResponseAssertions