Browser mixin

Browser automation interface for interacting with web pages.

Defines a unified API for browser automation across both synchronous and asynchronous WebDriver implementations. Provides navigation, DOM manipulation, event simulation, and assertion capabilities.

Basic usage:

// Navigate to a URL
await browser.visit('/login');

// Interact with elements
await browser.type('input[name="email"]', 'user@example.com');
await browser.type('input[name="password"]', 'password');
await browser.click('button[type="submit"]');

// Wait for elements
await browser.waiter.waitFor('.welcome-message');

// Make assertions
await browser.assertSee('Welcome back');
await browser.assertPresent('.user-menu');

The interface provides specialized handlers for different aspects:

Properties

cookies → Cookie
Handler for cookie operations.
no setter
dialogs → DialogHandler
Handler for dialog operations.
no setter
download → Download
Handler for download operations.
no setter
emulation → Emulation
Handler for device emulation.
no setter
frames → FrameHandler
Handler for frame operations.
no setter
hashCode int
The hash code for this object.
no setterinherited
keyboard → Keyboard
Handler for keyboard operations.
no setter
localStorage → LocalStorage
Handler for localStorage operations.
no setter
mouse → Mouse
Handler for mouse operations.
no setter
network → Network
Handler for network operations.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sessionStorage → SessionStorage
Handler for sessionStorage operations.
no setter
waiter → BrowserWaiter
Handler for waiting operations.
no setter
window → WindowManager
Handler for window operations.
no setter

Methods

assertAuthenticated([String? guard]) FutureOr<Browser>
Asserts that the user is authenticated.
inherited
assertChecked(String field) FutureOr<Browser>
Asserts that a checkbox or radio button is checked.
inherited
assertDisabled(String field) FutureOr<Browser>
Asserts that a form field is disabled.
inherited
assertDontSee(String text) FutureOr<Browser>
Asserts that the page does not contain the specified text.
inherited
assertDontSeeIn(String selector, String text) FutureOr<Browser>
Asserts that the specified element does not contain the given text.
inherited
assertEnabled(String field) FutureOr<Browser>
Asserts that a form field is enabled.
inherited
assertFocused(String field) FutureOr<Browser>
Asserts that a form field has focus.
inherited
assertGuest([String? guard]) FutureOr<Browser>
Asserts that the user is a guest (not authenticated).
inherited
assertInputMissing(String name) FutureOr<Browser>
Asserts that no input field with the specified name is present.
inherited
assertInputPresent(String name) FutureOr<Browser>
Asserts that an input field with the specified name is present.
inherited
assertInputValue(String field, String value) FutureOr<Browser>
Asserts that an input field has the specified value.
inherited
assertInputValueIsNot(String field, String value) FutureOr<Browser>
Asserts that an input field does not have the specified value.
inherited
assertMissing(String selector) FutureOr<Browser>
Asserts that no element matching the selector is present in the DOM.
inherited
assertNotChecked(String field) FutureOr<Browser>
Asserts that a checkbox or radio button is not checked.
inherited
assertNotFocused(String field) FutureOr<Browser>
Asserts that a form field does not have focus.
inherited
assertNotPresent(String selector) FutureOr<Browser>
Asserts that no element matching the selector is present in the DOM.
inherited
assertNotSelected(String field, String value) FutureOr<Browser>
Asserts that an option with the specified value is not selected in a select element.
inherited
assertPathBeginsWith(String path) FutureOr<Browser>
Asserts that the URL path begins with the specified prefix.
inherited
assertPathEndsWith(String path) FutureOr<Browser>
Asserts that the URL path ends with the specified suffix.
inherited
assertPathIs(String path) FutureOr<Browser>
Asserts that the URL path exactly matches the expected path.
inherited
assertPresent(String selector) FutureOr<Browser>
Asserts that an element matching the selector is present in the DOM.
inherited
assertQueryStringHas(String name, [String? value]) FutureOr<Browser>
Asserts that the URL query string contains the specified parameter.
inherited
assertQueryStringMissing(String name) FutureOr<Browser>
Asserts that the URL query string does not contain the specified parameter.
inherited
assertRadioNotSelected(String field, String value) FutureOr<Browser>
Asserts that a radio button with the specified name and value is not selected.
inherited
assertRadioSelected(String field, String value) FutureOr<Browser>
Asserts that a radio button with the specified name and value is selected.
inherited
assertSee(String text) FutureOr<Browser>
Asserts that the page contains the specified text.
inherited
assertSeeAnythingIn(String selector) FutureOr<Browser>
Asserts that the specified element contains any text.
inherited
assertSeeIn(String selector, String text) FutureOr<Browser>
Asserts that the specified element contains the given text.
inherited
assertSeeNothingIn(String selector) FutureOr<Browser>
Asserts that the specified element contains no text.
inherited
assertSelected(String field, String value) FutureOr<Browser>
Asserts that an option with the specified value is selected in a select element.
inherited
assertTitle(String title) FutureOr<Browser>
Asserts that the page title exactly matches the expected title.
inherited
assertTitleContains(String text) FutureOr<Browser>
Asserts that the page title contains the specified text.
inherited
assertUrlIs(String url) FutureOr<Browser>
Asserts that the current URL exactly matches the expected URL.
inherited
assertVisible(String selector) FutureOr<Browser>
Asserts that an element matching the selector is visible on the page.
inherited
back() FutureOr<void>
Navigates back in the browser history.
check(String selector) FutureOr<void>
Checks a checkbox or radio button.
click(String selector) FutureOr<void>
Clicks on an element identified by the selector.
Clicks on a link containing the specified text.
dumpPageSource() FutureOr<void>
Dumps the current page source to the console or log.
executeScript(String script) FutureOr
Executes JavaScript code in the browser context.
fillForm(Map<String, String> data) FutureOr<void>
Fills multiple form fields at once.
findElement(String selector) FutureOr
Finds an element in the DOM by its CSS selector.
forward() FutureOr<void>
Navigates forward in the browser history.
getCurrentUrl() FutureOr<String>
Returns the current URL of the browser.
getElementAttribute(String selector, String attribute) FutureOr<String?>
Gets the value of an attribute from an element.
getElementText(String selector) FutureOr<String>
Gets the text content of an element.
getPageSource() FutureOr<String>
Returns the HTML source of the current page.
getTitle() FutureOr<String>
Returns the title of the current page.
isPresent(String selector) FutureOr<bool>
Returns whether an element exists in the DOM.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pause(Duration duration) FutureOr<void>
Pauses execution for the specified duration.
quit() FutureOr<void>
Quits the browser and closes all associated windows.
refresh() FutureOr<void>
Refreshes the current page.
scrollTo(String selector) FutureOr<void>
Scrolls to a specific element on the page.
scrollToBottom() FutureOr<void>
Scrolls to the bottom of the page.
scrollToTop() FutureOr<void>
Scrolls to the top of the page.
selectOption(String selector, String value) FutureOr<void>
Selects an option from a dropdown/select element.
shouldBeChecked(String selector) FutureOr<Browser>
Laravel Dusk-style alias for assertChecked.
inherited
shouldBeDisabled(String selector) FutureOr<Browser>
Laravel Dusk-style alias for assertDisabled.
inherited
shouldBeEnabled(String selector) FutureOr<Browser>
Laravel Dusk-style alias for assertEnabled.
inherited
shouldBeOn(String url) FutureOr<Browser>
Laravel Dusk-style alias for assertUrlIs.
inherited
shouldHaveElement(String selector) FutureOr<Browser>
Laravel Dusk-style alias for assertPresent.
inherited
shouldHaveTitle(String title) FutureOr<Browser>
Laravel Dusk-style alias for assertTitle.
inherited
shouldHaveValue(String selector, String value) FutureOr<Browser>
Laravel Dusk-style alias for assertInputValue.
inherited
shouldNotHaveElement(String selector) FutureOr<Browser>
Laravel Dusk-style alias for assertNotPresent.
inherited
shouldNotSee(String text) FutureOr<Browser>
Laravel Dusk-style alias for assertDontSee.
inherited
shouldSee(String text) FutureOr<Browser>
Laravel Dusk-style alias for assertSee.
inherited
submitForm([String? selector]) FutureOr<void>
Submits a form.
takeScreenshot([String? name]) FutureOr<void>
Takes a screenshot of the current page.
toString() String
A string representation of this object.
inherited
type(String selector, String value) FutureOr<void>
Types text into an input element identified by the selector.
uncheck(String selector) FutureOr<void>
Unchecks a checkbox.
uploadFile(String selector, String filePath) FutureOr<void>
Uploads a file to a file input element.
visit(String url) FutureOr<void>
Navigates to the specified URL.
waitForElement(String selector, {Duration? timeout}) FutureOr<void>
Waits for an element to appear in the DOM.
waitForText(String text, {Duration? timeout}) FutureOr<void>
Waits for specific text to appear on the page.
waitForUrl(String url, {Duration? timeout}) FutureOr<void>
Waits for the browser to navigate to a specific URL.
waitUntil(FutureOr<bool> predicate(), {Duration? timeout, Duration interval = const Duration(milliseconds: 100)}) FutureOr<void>
Waits until a condition is true or timeout occurs.

Operators

operator ==(Object other) bool
The equality operator.
inherited