Yes, you can generate and run tests without manually creating
.spec files using Playwright's codegen feature.
To start, run the codegen command with the URL of the website you want to test:
npx playwright codegen https://ray.run/
This opens two windows: a browser window for interacting with the website, and the Playwright Inspector window for recording your tests.
As you interact with the website, Playwright generates code for user interactions. The generated locators prioritize role, text, and test id locators, making them resilient and uniquely identifying target elements.
To run your generated tests, use the
npx playwright test command followed by file names or directories containing the test files:
npx playwright test my-tests/
You can specify which browsers to use for testing with the
npx playwright test --browser chromium
Other useful options include:
--headed: Run tests in headed browsers for easier debugging.
--debug: Run tests with Playwright Inspector.
--max-failures <N>: Stop after N number of failures.
--output <dir>: Specify the directory for artifacts produced by your tests.
With Playwright's codegen feature, you can easily generate and run custom automated UI functional end-to-end tests without manually creating
If you still have questions, please ask a question and I will try to answer it.
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email email@example.com.