testing php applications
Browser Testing With Playwright, Selenium, Dusk, And Codeception
Several tools can automate browsers around PHP applications. Playwright is a modern cross-browser tool. Selenium remains widely used. Laravel Dusk integrates browser testing with Laravel. Codeception provides acceptance-testing workflows in PHP.
Follow The Existing Stack
Choose the tool that fits the repository, team, framework, and CI environment. A project with stable Dusk tests usually does not need a Playwright rewrite merely because Playwright is newer.
Keep Browser Coverage Narrow
Automate a small set of business-critical journeys, seed deterministic state, use stable selectors, and capture failure evidence. Keep validation matrices and calculation boundaries in faster lower-level tests.
import { test, expect } from '@playwright/test';
test('customer sees an order confirmation', async ({ page }) => {
await page.goto('/basket');
await page.getByRole('button', { name: 'Checkout' }).click();
await expect(page.getByRole('heading', { name: 'Order confirmed' })).toBeVisible();
});
Common Mistakes
- Rewriting an established browser suite without a clear benefit.
- Using CSS implementation details as selectors.
- Testing every validation branch through a browser.
- Ignoring screenshots, traces, and console failures.
What To Practise
- Recognise common browser tools.
- Choose based on repository context.
- Write stable focused browser journeys.
Practice
Practice: Choose A Browser Tool
Recommend a browser-testing approach for a Laravel application with an existing maintained Dusk suite.
Requirements
- Account for existing tests.
- Keep migration cost visible.
- Name conditions that could justify another tool.
- Preserve critical journeys during any trial.
Show solution
The existing suite is the default starting point.
Keep Dusk while the existing suite remains maintained and useful. Trial another tool only for a concrete missing capability or maintenance benefit, and preserve the critical journeys during that trial.
Tool changes should improve reliability, capability, or maintenance enough to justify migration cost.