Auto-Browse seamlessly integrates with playwright-bdd to enable behavior-driven development. This integration allows you to write expressive feature files and implement steps using natural language commands.
Create Gherkin feature files to describe your test scenarios:
Copy
# features/homepage.featureFeature: Playwright Home Page Scenario: Check title Given navigate to https://playwright.dev When click link "Get started" Then assert title "Installation"
Implement your steps using Auto-Browse’s natural language commands:
Note, you only need one step definition for the When step, as it will handle all actions.
(It can be when, given or then either of one step)
Copy
import { auto } from "@auto-browse/auto-browse";import { Given, When as aistep, Then } from "./fixtures";// Generic step that handles any natural language actionaistep(/^(.*)$/, async ({ page }, action: string) => { await auto(action, { page });});
# features/login.featureFeature: User Login Scenario: Successful login Given navigate to the login page When enter "user@example.com" in email field And enter "password123" in password field And click the login button Then verify dashboard is visible And check welcome message contains "Hello, User"
import { auto } from "@auto-browse/auto-browse";import { Given, When as aistep, Then } from "./fixtures";// Generic step that handles any natural language actionaistep(/^(.*)$/, async ({ page }, action: string) => { await auto(action, { page });});