diff --git a/browser-testing.md b/browser-testing.md
index 7a72a47..1a00ff1 100644
--- a/browser-testing.md
+++ b/browser-testing.md
@@ -1,46 +1,290 @@
---
title: Browser Testing
-description:
+description: Browser testing enables you to automate web application interactions in real browsers, helping you validate functionality across different browsers and devices.
---
# Browser Testing
-Browser testing is an essential part of modern web development, allowing you to ensure that your application works correctly across different browsers and devices. Pest provides a simple and elegant way to write browser tests. Here is an example of how to write a browser test using Pest:
+Pest's browser testing plugin provides a powerful API for automating browser interactions. Here's everything you need to know to get started:
+
+```bash
+# Installation
+composer require pestphp/pest-plugin-browser --dev
+npm install playwright@latest
+npx playwright install
+```
+
+## Basic Usage
```php
-it('may welcome the user', function () {
- $page = visit('/');
+test('user can log in', function () {
+ visit('/login')
+ ->type('email', 'test@example.com')
+ ->type('password', 'password')
+ ->click('Login')
+ ->assertPathIs('/dashboard');
+});
+```
+
+## Available Methods
+
+
+
+### Navigation
+
+- [visit()](#visit) - Visit a URL
+- [navigate()](#navigate) - Navigate to another URL
+- [back()](#back) - Go back
+- [forward()](#forward) - Go forward
+- [refresh()](#refresh) - Refresh page
+
+### Interactions
+
+- [click()](#click) - Click element
+- [type()](#type) - Type text
+- [select()](#select) - Select option
+- [check()](#check) - Check checkbox
+- [uncheck()](#uncheck) - Uncheck checkbox
+- [attach()](#attach) - Attach file
+- [press()](#press) - Press key
+- [hover()](#hover) - Hover over element
+- [drag()](#drag) - Drag element
+
+### Assertions
+
+- [assertSee()](#assert-see) - Assert text visible
+- [assertDontSee()](#assert-dont-see) - Assert text not visible
+- [assertTitle()](#assert-title) - Assert page title
+- [assertUrlIs()](#assert-url-is) - Assert current URL
+- [assertPathIs()](#assert-path-is) - Assert current path
+- [assertVisible()](#assert-visible) - Assert element visible
+- [assertMissing()](#assert-missing) - Assert element not visible
+- [assertValue()](#assert-value) - Assert input value
+
+### Device & Network
+
+- [mobile()](#mobile) - Mobile viewport
+- [tablet()](#tablet) - Tablet viewport
+- [desktop()](#desktop) - Desktop viewport
+- [setNetwork()](#set-network) - Set network conditions
+- [setGeolocation()](#set-geolocation) - Set location
+
+### Debug & Screenshots
+
+- [screenshot()](#screenshot) - Take screenshot
+- [debug()](#debug) - Start debugging
+- [pause()](#pause) - Pause execution
+
+
+
+## Common Examples
+
+### Form Testing
- $page->assertSee('Welcome');
+```php
+test('contact form submission', function () {
+ visit('/contact')
+ ->type('name', 'John Doe')
+ ->type('email', 'john@example.com')
+ ->type('message', 'Hello')
+ ->attach('attachment', '/path/to/file.pdf')
+ ->click('Submit')
+ ->assertSee('Message sent successfully');
});
```
-This is a basic example of a browser test that checks if the homepage contains the text "Welcome". However, Pest's browser testing capabilities go beyond this simple example. You can use various methods to interact with the page, such as clicking buttons, filling out forms, and navigating between pages.
+### Responsive Testing
+
+```php
+test('menu is responsive', function () {
+ visit('/')
+ ->desktop()
+ ->assertVisible('#desktop-menu')
+ ->assertMissing('#mobile-menu')
+ ->mobile()
+ ->assertVisible('#mobile-menu')
+ ->assertMissing('#desktop-menu');
+});
+```
-Here is an example of a more complex browser test, on Laravel, that checks if a user can sign in:
+### Multi-page Testing
```php
-it('may sign in the user', function () {
- Event::fake();
+test('multiple pages', function () {
+ $pages = visit(['/', '/about']);
+ [$home, $about] = $pages;
- User::factory()->create([ // assumes RefreshDatabase trait is used on Pest.php...
- 'email' => 'nuno@laravel.com',
- 'password' => 'password',
- ]);
+ $home->assertSee('Welcome');
+ $about->assertSee('About Us');
+});
+```
+
+### Error Handling
+
+```php
+test('form validation', function () {
+ visit('/register')
+ ->click('Register')
+ ->assertSee('Email is required')
+ ->type('email', 'invalid')
+ ->click('Register')
+ ->assertSee('Valid email required')
+ ->assertPathIs('/register');
+});
+```
+
+## Configuration
+
+Configure browser testing in your `Pest.php`:
+
+- `inChrome()` - Use Chrome (default)
+- `inFirefox()` - Use Firefox
+- `timeout(10000)` - Set timeout (ms)
+- `headed()` - Show browser
+- `headless()` - Hide browser (default)
+
+```php
+pest()->browser()
+ ->inChrome()
+ ->inFirefox()
+ ->timeout(10000)
+ ->headed()
+ ->headless();
+```
+
+
+
+[Installation](#installation)
+[Basic Usage](#basic-usage)
+[Navigation](#navigation)
+[Element Interactions](#element-interactions)
+[Assertions](#assertions)
+[Screenshots](#screenshots)
+[Device Emulation](#device-emulation)
+[Network Conditions](#network-conditions)
+[Console and Errors](#console-and-errors)
+[Frames and Windows](#frames-and-windows)
+[Geolocation](#geolocation)
+[Accessibility Testing](#accessibility-testing)
+
+
+
+## Table of Contents
+
+- [Getting Started](#getting-started)
+
+ - [Installation](#installation)
+ - [Basic Configuration](#basic-configuration)
+ - [Running Tests](#running-tests)
+
+- [Core Features](#core-features)
+
+ - [Navigation and Page Interaction](#navigation-and-page-interaction)
+ - [Screen Interactions](#screen-interactions)
+ - [Frame Handling](#frame-handling)
+ - [Tab Management](#tab-management)
+ - [Viewport Control](#viewport-control)
+ - [Toolbar Operations](#toolbar-operations)
+
+- [Testing Capabilities](#testing-capabilities)
+
+ - [Element Interactions](#element-interactions)
+ - [Form Handling](#form-handling)
+ - [Mouse and Keyboard](#mouse-and-keyboard)
+ - [Screenshots](#screenshots)
+ - [Console and Network](#console-and-network)
+
+- [Assertions](#assertions)
+
+ - [Element Assertions](#element-assertions)
+ - [URL Assertions](#url-assertions)
+ - [Console Assertions](#console-assertions)
+ - [Screenshot Assertions](#screenshot-assertions)
+
+- [Advanced Features](#advanced-features)
+
+ - [Multiple Page Testing](#multiple-page-testing)
+ - [Location Simulation](#location-simulation)
+ - [Device Emulation](#device-emulation)
+ - [Livewire Support](#livewire-support)
+
+- [Configuration](#configuration)
+
+ - [Browser Options](#browser-options)
+ - [Viewport Settings](#viewport-settings)
+ - [Network Conditions](#network-conditions)
+ - [Screenshot Settings](#screenshot-settings)
+
+- [Debugging](#debugging)
+ - [Visual Debugging](#visual-debugging)
+ - [Console Debugging](#console-debugging)
+ - [Network Debugging](#network-debugging)
+
+## Getting Started
+
+
-[assertTitle](#assert-title)
-[assertTitleContains](#assert-title-contains)
-[assertSee](#assert-see)
-[assertDontSee](#assert-dont-see)
-[assertSeeIn](#assert-see-in)
-[assertDontSeeIn](#assert-dont-see-in)
-[assertSeeAnythingIn](#assert-see-anything-in)
-[assertSeeNothingIn](#assert-see-nothing-in)
-[assertCount](#assert-count)
-[assertScript](#assert-script)
-[assertSourceHas](#assert-source-has)
-[assertSourceMissing](#assert-source-missing)
-[assertSeeLink](#assert-see-link)
-[assertDontSeeLink](#assert-dont-see-link)
-[assertChecked](#assert-checked)
-[assertNotChecked](#assert-not-checked)
-[assertIndeterminate](#assert-indeterminate)
-[assertRadioSelected](#assert-radio-selected)
-[assertRadioNotSelected](#assert-radio-not-selected)
-[assertSelected](#assert-selected)
-[assertNotSelected](#assert-not-selected)
-[assertValue](#assert-value)
-[assertValueIsNot](#assert-value-is-not)
-[assertAttribute](#assert-attribute)
-[assertAttributeMissing](#assert-attribute-missing)
-[assertAttributeContains](#assert-attribute-contains)
-[assertAttributeDoesntContain](#assert-attribute-doesnt-contain)
-[assertAriaAttribute](#assert-aria-attribute)
-[assertDataAttribute](#assert-data-attribute)
-[assertVisible](#assert-visible)
-[assertPresent](#assert-present)
-[assertNotPresent](#assert-not-present)
-[assertMissing](#assert-missing)
-[assertEnabled](#assert-enabled)
-[assertDisabled](#assert-disabled)
-[assertButtonEnabled](#assert-button-enabled)
-[assertButtonDisabled](#assert-button-disabled)
-[assertUrlIs](#assert-url-is)
-[assertSchemeIs](#assert-scheme-is)
-[assertSchemeIsNot](#assert-scheme-is-not)
-[assertHostIs](#assert-host-is)
-[assertHostIsNot](#assert-host-is-not)
-[assertPortIs](#assert-port-is)
-[assertPortIsNot](#assert-port-is-not)
-[assertPathBeginsWith](#assert-path-begins-with)
-[assertPathEndsWith](#assert-path-ends-with)
-[assertPathContains](#assert-path-contains)
-[assertPathIs](#assert-path-is)
-[assertPathIsNot](#assert-path-is-not)
-[assertQueryStringHas](#assert-query-string-has)
-[assertQueryStringMissing](#assert-query-string-missing)
-[assertFragmentIs](#assert-fragment-is)
-[assertFragmentBeginsWith](#assert-fragment-begins-with)
-[assertFragmentIsNot](#assert-fragment-is-not)
-[assertNoSmoke](#assert-no-smoke)
-[assertNoConsoleLogs](#assert-no-console-logs)
-[assertNoJavaScriptErrors](#assert-no-javascript-errors)
-[assertNoAccessibilityIssues](#assert-no-accessibility-issues)
-[assertScreenshotMatches](#assert-screenshot-matches)
+Content Assertions:
+
+- [assertSee](#assert-see) - Assert text is visible on page
+- [assertDontSee](#assert-dont-see) - Assert text is not visible on page
+- [assertSeeIn](#assert-see-in) - Assert text is visible in selector
+- [assertDontSeeIn](#assert-dont-see-in) - Assert text is not visible in selector
+- [assertSeeAnythingIn](#assert-see-anything-in) - Assert any content in selector
+- [assertSeeNothingIn](#assert-see-nothing-in) - Assert no content in selector
+- [assertCount](#assert-count) - Assert element count matches
+
+Element Assertions:
+
+- [assertTitle](#assert-title) - Assert page title matches
+- [assertTitleContains](#assert-title-contains) - Assert page title contains text
+- [assertVisible](#assert-visible) - Assert element is visible
+- [assertPresent](#assert-present) - Assert element exists in DOM
+- [assertNotPresent](#assert-not-present) - Assert element doesn't exist
+- [assertMissing](#assert-missing) - Assert element is not visible
+
+Form Assertions:
+
+- [assertValue](#assert-value) - Assert input value matches
+- [assertValueIsNot](#assert-value-is-not) - Assert input value doesn't match
+- [assertChecked](#assert-checked) - Assert checkbox is checked
+- [assertNotChecked](#assert-not-checked) - Assert checkbox is not checked
+- [assertIndeterminate](#assert-indeterminate) - Assert checkbox is indeterminate
+- [assertRadioSelected](#assert-radio-selected) - Assert radio is selected
+- [assertRadioNotSelected](#assert-radio-not-selected) - Assert radio not selected
+- [assertSelected](#assert-selected) - Assert dropdown option selected
+- [assertNotSelected](#assert-not-selected) - Assert option not selected
+- [assertEnabled](#assert-enabled) - Assert field is enabled
+- [assertDisabled](#assert-disabled) - Assert field is disabled
+- [assertButtonEnabled](#assert-button-enabled) - Assert button enabled
+- [assertButtonDisabled](#assert-button-disabled) - Assert button disabled
+
+URL Assertions:
+
+- [assertUrlIs](#assert-url-is) - Assert full URL matches
+- [assertSchemeIs](#assert-scheme-is) - Assert URL scheme matches
+- [assertSchemeIsNot](#assert-scheme-is-not) - Assert scheme doesn't match
+- [assertHostIs](#assert-host-is) - Assert URL host matches
+- [assertHostIsNot](#assert-host-is-not) - Assert host doesn't match
+- [assertPortIs](#assert-port-is) - Assert URL port matches
+- [assertPortIsNot](#assert-port-is-not) - Assert port doesn't match
+- [assertPathIs](#assert-path-is) - Assert URL path matches
+- [assertPathIsNot](#assert-path-is-not) - Assert path doesn't match
+- [assertPathBeginsWith](#assert-path-begins-with) - Assert path starts with
+- [assertPathEndsWith](#assert-path-ends-with) - Assert path ends with
+- [assertPathContains](#assert-path-contains) - Assert path contains
+- [assertQueryStringHas](#assert-query-string-has) - Assert query param exists
+- [assertQueryStringMissing](#assert-query-string-missing) - Assert no query param
+- [assertFragmentIs](#assert-fragment-is) - Assert URL fragment matches
+- [assertFragmentBeginsWith](#assert-fragment-begins-with) - Assert fragment starts
+- [assertFragmentIsNot](#assert-fragment-is-not) - Assert fragment doesn't match
+
+Source Assertions:
+
+- [assertScript](#assert-script) - Assert JS expression result
+- [assertSourceHas](#assert-source-has) - Assert source contains code
+- [assertSourceMissing](#assert-source-missing) - Assert source lacks code
+- [assertSeeLink](#assert-see-link) - Assert link exists
+- [assertDontSeeLink](#assert-dont-see-link) - Assert link doesn't exist
+
+Attribute Assertions:
+
+- [assertAttribute](#assert-attribute) - Assert attribute value matches
+- [assertAttributeMissing](#assert-attribute-missing) - Assert no attribute
+- [assertAttributeContains](#assert-attribute-contains) - Assert attribute contains
+- [assertAttributeDoesntContain](#assert-attribute-doesnt-contain) - Assert not in attribute
+- [assertAriaAttribute](#assert-aria-attribute) - Assert ARIA attribute
+- [assertDataAttribute](#assert-data-attribute) - Assert data attribute
+
+Debug Assertions:
+
+- [assertNoSmoke](#assert-no-smoke) - Assert no console errors
+- [assertNoConsoleLogs](#assert-no-console-logs) - Assert no console logs
+- [assertNoJavaScriptErrors](#assert-no-javascript-errors) - Assert no JS errors
+- [assertNoAccessibilityIssues](#assert-no-accessibility-issues) - Assert accessible
+- [assertScreenshotMatches](#assert-screenshot-matches) - Assert visual match
@@ -306,33 +1363,47 @@ $page->assertSee('Welcome, bot!');
-[click](#click)
-[text](#text)
-[attribute](#attribute)
-[keys](#keys)
-[withKeyDown](#withKeyDown)
-[type](#type)
-[typeSlowly](#type-slowly)
-[select](#select)
-[append](#append)
-[clear](#clear)
-[radio](#radio)
-[check](#check)
-[uncheck](#uncheck)
-[attach](#attach)
-[press](#press)
-[pressAndWaitFor](#press-and-wait-for)
-[drag](#drag)
-[hover](#hover)
-[submit](#submit)
-[value](#value)
-[withinIframe](#within-iframe)
-[resize](#resize)
-[script](#script)
-[content](#content)
-[url](#url)
-[wait](#wait)
-[waitForKey](#wait-for-key)
+Mouse Interactions:
+
+- [click](#click) - Click an element
+- [hover](#hover) - Hover over element
+- [drag](#drag) - Drag and drop elements
+
+Form Interactions:
+
+- [type](#type) - Type text into input
+- [typeSlowly](#type-slowly) - Type text with delay
+- [select](#select) - Select dropdown option
+- [append](#append) - Add text to existing input
+- [clear](#clear) - Clear input field
+- [radio](#radio) - Select radio button
+- [check](#check) - Check checkbox
+- [uncheck](#uncheck) - Uncheck checkbox
+- [attach](#attach) - Upload file
+- [submit](#submit) - Submit form
+
+Button/Key Interactions:
+
+- [press](#press) - Press a button
+- [pressAndWaitFor](#press-and-wait-for) - Press and wait
+- [keys](#keys) - Send keyboard input
+- [withKeyDown](#withKeyDown) - Hold key while executing
+
+Element State:
+
+- [text](#text) - Get element text
+- [attribute](#attribute) - Get element attribute
+- [value](#value) - Get input value
+- [withinIframe](#within-iframe) - Work with iframes
+
+Page Control:
+
+- [resize](#resize) - Resize browser window
+- [script](#script) - Execute JavaScript
+- [content](#content) - Get page content
+- [url](#url) - Get current URL
+- [wait](#wait) - Wait for duration
+- [waitForKey](#wait-for-key) - Wait for keypress
@@ -340,17 +1411,26 @@ $page->assertSee('Welcome, bot!');
-[debug](#debug)
-[screenshot](#screenshot)
-[screenshotElement](#screenshot-element)
-[tinker](#tinker)
-[headed](#headed)
+Debugging Tools:
+
+- [debug](#debug) - Enable debugging mode
+- [tinker](#tinker) - Interactive debugging session
+
+Screenshot Tools:
+
+- [screenshot](#screenshot) - Capture page screenshot
+- [screenshotElement](#screenshot-element) - Capture element screenshot
+
+Browser Display:
+
+- [headed](#headed) - Show browser window while testing
## Element Assertions
');
```
+
### assertSeeLink
The `assertSeeLink` method asserts that the given link is present on the page:
@@ -469,6 +1561,7 @@ $page->assertSeeLink('About Us');
```
+
### assertDontSeeLink
The `assertDontSeeLink` method asserts that the given link is not present on the page:
@@ -478,6 +1571,7 @@ $page->assertDontSeeLink('Admin Panel');
```
+
### assertChecked
The `assertChecked` method asserts that the given checkbox is checked:
@@ -488,6 +1582,7 @@ $page->assertChecked('color', 'blue'); // For checkbox with specific value
```
+
### assertNotChecked
The `assertNotChecked` method asserts that the given checkbox is not checked:
@@ -498,6 +1593,7 @@ $page->assertNotChecked('color', 'red'); // For checkbox with specific value
```
+
### assertIndeterminate
The `assertIndeterminate` method asserts that the given checkbox is in an indeterminate state:
@@ -507,6 +1603,7 @@ $page->assertIndeterminate('partial-selection');
```
+
### assertRadioSelected
The `assertRadioSelected` method asserts that the given radio field is selected:
@@ -516,6 +1613,7 @@ $page->assertRadioSelected('size', 'large');
```
+
### assertRadioNotSelected
The `assertRadioNotSelected` method asserts that the given radio field is not selected:
@@ -525,6 +1623,7 @@ $page->assertRadioNotSelected('size', 'small');
```
+
### assertSelected
The `assertSelected` method asserts that the given dropdown has the given value selected:
@@ -534,6 +1633,7 @@ $page->assertSelected('country', 'US');
```
+
### assertNotSelected
The `assertNotSelected` method asserts that the given dropdown does not have the given value selected:
@@ -543,6 +1643,7 @@ $page->assertNotSelected('country', 'UK');
```
+
### assertValue
The `assertValue` method asserts that the element matching the given selector has the given value:
@@ -552,6 +1653,7 @@ $page->assertValue('input[name=email]', 'test@example.com');
```
+
### assertValueIsNot
The `assertValueIsNot` method asserts that the element matching the given selector does not have the given value:
@@ -561,6 +1663,7 @@ $page->assertValueIsNot('input[name=email]', 'invalid@example.com');
```
+
### assertAttribute
The `assertAttribute` method asserts that the element matching the given selector has the given value in the provided attribute:
@@ -570,6 +1673,7 @@ $page->assertAttribute('img', 'alt', 'Profile Picture');
```
+
### assertAttributeMissing
The `assertAttributeMissing` method asserts that the element matching the given selector is missing the provided attribute:
@@ -579,6 +1683,7 @@ $page->assertAttributeMissing('button', 'disabled');
```
+
### assertAttributeContains
The `assertAttributeContains` method asserts that the element matching the given selector contains the given value in the provided attribute:
@@ -588,6 +1693,7 @@ $page->assertAttributeContains('div', 'class', 'container');
```
+
### assertAttributeDoesntContain
The `assertAttributeDoesntContain` method asserts that the element matching the given selector does not contain the given value in the provided attribute:
@@ -597,6 +1703,7 @@ $page->assertAttributeDoesntContain('div', 'class', 'hidden');
```
+
### assertAriaAttribute
The `assertAriaAttribute` method asserts that the element matching the given selector has the given value in the provided aria attribute:
@@ -606,6 +1713,7 @@ $page->assertAriaAttribute('button', 'label', 'Close');
```
+
### assertDataAttribute
The `assertDataAttribute` method asserts that the element matching the given selector has the given value in the provided data attribute:
@@ -615,6 +1723,7 @@ $page->assertDataAttribute('div', 'id', '123');
```
+
### assertVisible
The `assertVisible` method asserts that the element matching the given selector is visible:
@@ -624,6 +1733,7 @@ $page->assertVisible('.alert');
```
+
### assertPresent
The `assertPresent` method asserts that the element matching the given selector is present in the DOM:
@@ -633,6 +1743,7 @@ $page->assertPresent('form');
```
+
### assertNotPresent
The `assertNotPresent` method asserts that the element matching the given selector is not present in the DOM:
@@ -642,6 +1753,7 @@ $page->assertNotPresent('.error-message');
```
+
### assertMissing
The `assertMissing` method asserts that the element matching the given selector is not visible:
@@ -651,6 +1763,7 @@ $page->assertMissing('.hidden-element');
```
+
### assertEnabled
The `assertEnabled` method asserts that the given field is enabled:
@@ -660,6 +1773,7 @@ $page->assertEnabled('email');
```
+
### assertDisabled
The `assertDisabled` method asserts that the given field is disabled:
@@ -669,6 +1783,7 @@ $page->assertDisabled('submit');
```
+
### assertButtonEnabled
The `assertButtonEnabled` method asserts that the given button is enabled:
@@ -678,6 +1793,7 @@ $page->assertButtonEnabled('Save');
```
+
### assertButtonDisabled
The `assertButtonDisabled` method asserts that the given button is disabled:
@@ -689,6 +1805,7 @@ $page->assertButtonDisabled('Submit');
## URL Assertions
+
### assertUrlIs
The `assertUrlIs` method asserts that the current URL matches the given string:
@@ -698,6 +1815,7 @@ $page->assertUrlIs('https://example.com/home');
```
+
### assertSchemeIs
The `assertSchemeIs` method asserts that the current URL scheme matches the given scheme:
@@ -707,6 +1825,7 @@ $page->assertSchemeIs('https');
```
+
### assertSchemeIsNot
The `assertSchemeIsNot` method asserts that the current URL scheme does not match the given scheme:
@@ -716,6 +1835,7 @@ $page->assertSchemeIsNot('http');
```
+
### assertHostIs
The `assertHostIs` method asserts that the current URL host matches the given host:
@@ -725,6 +1845,7 @@ $page->assertHostIs('example.com');
```
+
### assertHostIsNot
The `assertHostIsNot` method asserts that the current URL host does not match the given host:
@@ -734,6 +1855,7 @@ $page->assertHostIsNot('wrong-domain.com');
```
+
### assertPortIs
The `assertPortIs` method asserts that the current URL port matches the given port:
@@ -743,6 +1865,7 @@ $page->assertPortIs('443');
```
+
### assertPortIsNot
The `assertPortIsNot` method asserts that the current URL port does not match the given port:
@@ -752,6 +1875,7 @@ $page->assertPortIsNot('8080');
```
+
### assertPathBeginsWith
The `assertPathBeginsWith` method asserts that the current URL path begins with the given path:
@@ -761,6 +1885,7 @@ $page->assertPathBeginsWith('/users');
```
+
### assertPathEndsWith
The `assertPathEndsWith` method asserts that the current URL path ends with the given path:
@@ -770,6 +1895,7 @@ $page->assertPathEndsWith('/profile');
```
+
### assertPathContains
The `assertPathContains` method asserts that the current URL path contains the given path:
@@ -779,6 +1905,7 @@ $page->assertPathContains('settings');
```
+
### assertPathIs
The `assertPathIs` method asserts that the current path matches the given path:
@@ -788,6 +1915,7 @@ $page->assertPathIs('/dashboard');
```
+
### assertPathIsNot
The `assertPathIsNot` method asserts that the current path does not match the given path:
@@ -797,6 +1925,7 @@ $page->assertPathIsNot('/login');
```
+
### assertQueryStringHas
The `assertQueryStringHas` method asserts that the given query string parameter is present and has a given value:
@@ -807,6 +1936,7 @@ $page->assertQueryStringHas('page', '2');
```
+
### assertQueryStringMissing
The `assertQueryStringMissing` method asserts that the given query string parameter is missing:
@@ -816,6 +1946,7 @@ $page->assertQueryStringMissing('page');
```
+
### assertFragmentIs
The `assertFragmentIs` method asserts that the URL's current hash fragment matches the given fragment:
@@ -825,6 +1956,7 @@ $page->assertFragmentIs('section-2');
```
+
### assertFragmentBeginsWith
The `assertFragmentBeginsWith` method asserts that the URL's current hash fragment begins with the given fragment:
@@ -834,6 +1966,7 @@ $page->assertFragmentBeginsWith('section');
```
+
### assertFragmentIsNot
The `assertFragmentIsNot` method asserts that the URL's current hash fragment does not match the given fragment:
@@ -845,6 +1978,7 @@ $page->assertFragmentIsNot('wrong-section');
## Console Assertions
+
### assertNoSmoke
The `assertNoSmoke` method asserts there are no console logs or JavaScript errors on the page:
@@ -854,6 +1988,7 @@ $page->assertNoSmoke();
```
+
### assertNoConsoleLogs
The `assertNoConsoleLogs` method asserts there are no console logs on the page:
@@ -863,6 +1998,7 @@ $page->assertNoConsoleLogs();
```
+
### assertNoJavaScriptErrors
The `assertNoJavaScriptErrors` method asserts there are no JavaScript errors on the page:
@@ -872,6 +2008,7 @@ $page->assertNoJavaScriptErrors();
```
+
### assertNoAccessibilityIssues
The `assertNoAccessibilityIssues` method asserts there are no "serious" accessibility issues on the page:
@@ -897,6 +2034,7 @@ By default, the level is 1 (serious). You can change to one of the following lev
## Screenshot Assertions
+
### assertScreenshotMatches
The `assertScreenshotMatches` method asserts that the screenshot matches the expected image:
@@ -909,6 +2047,7 @@ $page->assertScreenshotMatches(true, true); // Full page, show diff
## Element Interactions
+
### click
The `click` method clicks the link with the given text:
@@ -924,6 +2063,7 @@ $page->click('#button', options: ['clickCount' => 2]);
```
+
### text
The `text` method gets the text of the element matching the given selector:
@@ -933,6 +2073,7 @@ $text = $page->text('.header');
```
+
### attribute
The `attribute` method gets the given attribute from the element matching the given selector:
@@ -942,6 +2083,7 @@ $alt = $page->attribute('img', 'alt');
```
+
### keys
The `keys` method sends the given keys to the element matching the given selector:
@@ -952,6 +2094,7 @@ $page->keys('input[name=password]', ['{Control}', 'a']); // Keyboard shortcuts
```
+
### withKeyDown
The `withKeyDown` method executes the given callback while a key is held down:
@@ -966,6 +2109,7 @@ $page->withKeyDown('Shift', function () use ($page): void {
> 'a' always types a lowercase “a” and 'A' always types an uppercase “A”, regardless of modifiers.
+
### type
The `type` method types the given value in the given field:
@@ -985,6 +2129,7 @@ $page->typeSlowly('email', 'test@example.com');
```
+
### select
The `select` method selects the given value in the given field:
@@ -995,6 +2140,7 @@ $page->select('interests', ['music', 'sports']); // Multiple select
```
+
### append
The `append` method types the given value in the given field without clearing it:
@@ -1004,6 +2150,7 @@ $page->append('description', ' Additional information.');
```
+
### clear
The `clear` method clears the given field:
@@ -1013,6 +2160,7 @@ $page->clear('search');
```
+
### radio
The `radio` method selects the given value of a radio button field:
@@ -1022,6 +2170,7 @@ $page->radio('size', 'large');
```
+
### check
The `check` method checks the given checkbox:
@@ -1032,6 +2181,7 @@ $page->check('color', 'blue'); // For checkbox with specific value
```
+
### uncheck
The `uncheck` method unchecks the given checkbox:
@@ -1042,6 +2192,7 @@ $page->uncheck('color', 'red'); // For checkbox with specific value
```
+
### attach
The `attach` method attaches the given file to the field:
@@ -1051,6 +2202,7 @@ $page->attach('avatar', '/path/to/image.jpg');
```
+
### press
The `press` method presses the button with the given text or name:
@@ -1060,6 +2212,7 @@ $page->press('Submit');
```
+
### pressAndWaitFor
The `pressAndWaitFor` method presses the button with the given text or name and waits for a specified amount of time:
@@ -1069,6 +2222,7 @@ $page->pressAndWaitFor('Submit', 2); // Wait for 2 seconds
```
+
### drag
The `drag` method drags an element to another element using selectors:
@@ -1078,6 +2232,7 @@ $page->drag('#item', '#target');
```
+
### hover
The `hover` method hovers over the given element:
@@ -1087,6 +2242,7 @@ $page->hover('#item');
```
+
### submit
The `submit` method submits the first form found on the page:
@@ -1096,6 +2252,7 @@ $page->submit();
```
+
### value
The `value` method gets the value of the element matching the given selector:
@@ -1130,6 +2287,7 @@ $page->resize(1280, 720);
```
+
### script
The `script` method executes a script in the context of the page:
@@ -1139,6 +2297,7 @@ $result = $page->script('document.title');
```
+
### content
The `content` method gets the page's content:
@@ -1148,6 +2307,7 @@ $html = $page->content();
```
+
### url
The `url` method gets the page's URL:
@@ -1157,6 +2317,7 @@ $currentUrl = $page->url();
```
+
### wait
The `wait` method pauses for the given number of seconds:
@@ -1166,6 +2327,7 @@ $page->wait(2); // Wait for 2 seconds
```
+
### waitForKey
The `waitForKey` method opens the current page URL in the default web browser and waits for a key press:
@@ -1189,7 +2351,6 @@ Optionally, you can also use the `debug()` method in your test. It will limit ex
$page->debug();
```
-
You can also take a screenshot of the current page using the `screenshot()` method. This is useful for visual debugging:
@@ -1235,17 +2396,19 @@ You may refer to Pest's [Continuous Integration](https://pestphp.com/docs/contin
However, if you are using GitHub Actions, you need to add the following steps to your workflow file:
```yaml
- - uses: actions/setup-node@v4
- with:
- node-version: lts/*
+- uses: actions/setup-node@v4
+ with:
+ node-version: lts/*
- - name: Install dependencies
- run: npm ci
+- name: Install dependencies
+ run: npm ci
- - name: Install Playwright Browsers
- run: npx playwright install --with-deps
+- name: Install Playwright Browsers
+ run: npx playwright install --with-deps
```
---
-Now, let's dive into architectural testing and how it can benefit your development process. By performing architectural testing, you can evaluate the overall design of your application and identify potential flaws before they become significant issues: [Arch Testing](/docs/arch-testing)
+In this section, you have learned how to perform browser testing with Pest, enabling you to verify your application's behavior in real browsers. From form interactions to network conditions, you now have the tools to ensure your web application works correctly across different browsers and devices.
+
+Next, let's explore how you can ensure your application's architecture remains clean and maintainable through [Arch Testing](/docs/arch-testing).