Cursor AI + Playwright Tutorial: How to Use Cursor Agent for Test Automation
AI Tool Directory Article | Cursor Agent + Playwright + Cucumber BDD
AI coding tools are usually introduced through programming examples: generate a function, fix a bug, refactor a component, or explain an unfamiliar repository. The workflow in this tutorial is more specific and, for QA engineers, arguably more useful. It shows how Cursor Agent can be applied to an existing Playwright automation project as a working assistant for understanding the framework, tracing a test flow, executing a scenario, diagnosing why it did not run, and finally extending the project with a new negative login test.
That sequence matters. The strongest part of the workflow is not simply that an AI agent can write test code. It is that the agent is asked to understand the project before changing it. The video repeatedly uses a useful safety pattern: first inspect, then explain, then run, then plan, and only after that make edits. For teams working with inherited automation code, that discipline is much more valuable than asking an agent to “write a Playwright test” with no context.
The example project is a Playwright-based OrangeHRM UI automation framework that also uses Cucumber BDD. That gives the agent several layers to reason about: Gherkin feature files, step definitions, page objects, hooks, configuration, utilities, services, test data, and the browser automation underneath. Instead of manually opening every file, the tutorial uses Cursor to build a map of how those pieces connect.
This article follows the full workflow shown in the video, but it also separates the creator’s project-specific setup from what Cursor, Playwright, and Cucumber officially support today.
1. Install Cursor and Open the Project You Actually Want to Understand
The tutorial begins with the normal setup process: download Cursor, install it, sign in, and open the application. The exact onboarding screens can change, but the basic process remains straightforward. Cursor’s current official download page provides desktop builds for macOS, Windows, and Linux, while its quickstart documentation starts with the same basic sequence: install, sign in, choose a folder, and begin with a small task.

The important idea is not the installer. It is what happens next. Cursor is positioned as an AI-enabled development environment rather than a chat window that happens to know about code. It has access to the files in the selected project and, when Agent is used, can search the codebase, edit files, and run terminal commands.
Current Cursor documentation describes Agent as an assistant for complex coding tasks that can search a repository, edit code, and execute commands. That lines up closely with the tutorial’s testing workflow because test automation work often requires all three activities at once. A useful agent needs to read the framework, understand conventions, call the correct runner, inspect output, and make narrowly scoped changes.
2. Understand the Difference Between Asking Questions and Giving an Agent a Task
Early in the video, the creator explains Cursor as a code editor combined with AI assistants and agents. The screen shown in the tutorial has an agent-focused interface and also an editor-style workspace that feels familiar to anyone coming from VS Code.

One detail from the recording should be treated as interface-specific rather than a permanent product rule. The tutorial describes an “Agent window” and an “IDE window” as two workspaces. Cursor’s current product language is broader: the desktop app is described as an agent-first workspace that still includes editor capabilities, and agents are also available through other surfaces such as the web and terminal. In other words, the video is accurately demonstrating the interface it recorded, but readers should not assume the exact arrangement will remain fixed across Cursor versions.

The model shown in the recording is Cursor Grok 4.6. That model still appears in Cursor’s current model documentation, but it is only one option in a changing model lineup. Cursor currently documents multiple Cursor, OpenAI, Anthropic, Google, and other model choices. For this workflow, the exact model name matters less than the agent capabilities: repository search, file reading, terminal execution, and controlled multi-file edits.
3. The Real Use Case: Joining an Existing Automation Project
The tutorial frames a common QA problem: imagine joining a team and receiving an existing automation framework that somebody else built. Traditionally, onboarding depends on another engineer walking you through the project structure, explaining how tests are launched, pointing out where features and page objects live, and answering questions about configuration.
An AI coding agent does not replace that domain knowledge, but it can shorten the first exploration pass. Because Cursor can inspect the entire opened repository, the agent can create a structured explanation of the codebase without requiring the user to manually click through every directory first.
The project in the video is not a plain Playwright Test repository. It is a Cucumber BDD plus Playwright UI automation framework aimed at OrangeHRM. That distinction becomes important later when the agent figures out how the tests are actually launched.
The creator opens the project folder inside Cursor and then gives a deliberately read-only prompt. The essence of the prompt is:
Analyze this Playwright project. Explain the overall project structure, execution flow, and purpose of the main folders. Do not modify any files.

That last sentence is one of the best habits in the entire tutorial. If your immediate goal is understanding, say so explicitly and prevent edits. Coding agents are optimized to act. When you only need analysis, a constraint such as “do not modify files” makes the task clearer and reduces the chance that the agent tries to improve code before you even understand the existing design.
For a quick overview of Cursor Agent, start at the Cursor tool profile.
4. Let the Agent Build a Map of the Test Framework
After receiving the prompt, Cursor starts exploring the repository. It reads files and returns an overview of the framework’s purpose, its execution flow, and its folder structure.
In the tutorial, the agent correctly identifies the repository as a Cucumber BDD and Playwright UI automation framework for OrangeHRM. It also notices something subtle: the project’s npm test command launches Cucumber rather than the Playwright Test runner. That is project-specific behavior defined by the package scripts, not a general rule about Playwright.
This is worth clarifying because Playwright itself ships with Playwright Test, a full end-to-end test framework with its own runner, assertions, isolation, parallelization, configuration, and reporting. A team can also use Playwright’s browser automation APIs underneath another test architecture, including Cucumber. In the tutorial’s repository, Cucumber is the layer that interprets the Gherkin scenarios and triggers the corresponding step definitions, while Playwright drives browser interactions.

The agent walks through the major areas of the repository, including feature files, step definitions, page objects, services, hooks, configuration, utilities, data, and constants. For a new team member, that kind of map is useful because it turns an unfamiliar tree of files into a conceptual architecture.
Feature files
Cucumber feature files contain Gherkin scenarios. Gherkin is designed to describe behavior using readable steps such as Given, When, and Then. The feature file describes what behavior should happen without containing all the low-level browser implementation.
Step definitions
Step definitions connect the plain-language Gherkin steps to executable code. Cucumber’s official documentation describes a step definition as the method or function that matches a Gherkin step and performs its action. In a Playwright-backed framework, those step definitions may call page-object methods or helper services that eventually interact with the browser.
Page objects
The page-object layer encapsulates selectors and reusable actions for a page or logical part of the application. In the tutorial’s login flow, the login page object contains the controls and methods needed to work with username, password, and login behavior.
Hooks and configuration
Cucumber hooks are commonly used for setup and teardown around scenarios. Configuration supplies values such as the base URL and other environment or execution settings. The agent surfaces these pieces so that the reader can see not only where the test starts, but also what surrounds it before and after execution.
The useful result is not merely a folder listing. Cursor gives the user a starting mental model of the entire framework.
5. Move From a Framework Overview to One Specific Business Flow
Trying to understand an entire automation framework in one pass can still be overwhelming. The tutorial therefore narrows the scope to the login functionality.
The next request asks Cursor to find the OrangeHRM login flow and explain how the feature file, step definitions, page object, hooks, and configuration work together. Again, the prompt tells the agent not to modify any files.
This is a better way to use repository-aware AI than repeatedly asking broad questions. Once the high-level map exists, choose one real workflow and follow it end to end.
For the login example, Cursor identifies the login feature, the scenario, the relevant hooks, the base URL configuration, the login step definitions, and the login page object. It then explains the end-to-end sequence.
This type of tracing is especially helpful in layered test frameworks. A single line in a .feature file may map to a step-definition function, which may call a page-object method, which may rely on shared base-page behavior, while browser lifecycle setup happens in hooks. An agent that can search across all of those files can assemble the chain much faster than a user manually guessing where each step leads.
6. Ask Cursor to Run the Existing Scenario, Not Just Explain It
Understanding the code is only half the job. The next step in the tutorial is execution.
The creator asks Cursor to run the existing valid OrangeHRM login scenario and report whether it passes or fails, while still telling the agent not to modify any files. This moves the agent from code search into terminal execution.
Cursor’s current documentation explicitly lists terminal execution as one of Agent’s tools. That capability is important for test automation because a correct explanation of a repository is not the same thing as a verified test result. Running the project exposes configuration issues, skipped tests, missing dependencies, environment problems, and application failures that static inspection alone cannot reveal.
In this case, the result is more interesting than a simple pass or fail.
7. A Good Agent Should Diagnose “Did Not Run” as a Third Outcome
The requested login scenario does not pass and does not fail. Cursor reports that the dedicated login scenario was not executed because the successful-login scenario in the feature file is commented out.

This is a small example, but it demonstrates an important testing lesson: execution status is not always binary. A test can be skipped, filtered out, commented, disabled, excluded by tags, or never discovered by the runner. If an AI assistant blindly reported “failed” whenever it could not produce a pass, it would be misleading.
The agent instead inspects the relevant feature file and explains the actual reason the scenario was not run. Because the user asked only for diagnosis, Cursor leaves the files untouched.
The video notes that the user could uncomment the scenario and try again. More generally, this is where human judgment should remain in the loop. The correct next step depends on why the test was disabled in the first place. An agent can find that it is commented out, but a team member may know whether it was intentionally disabled because of an environment issue, unstable test data, an unfinished feature, or a temporary maintenance decision.
8. Plan a New Test Before Letting the Agent Write It
The next task is to add negative login coverage. The existing framework has a valid login scenario, and the goal is to add an invalid login scenario using an incorrect username and password.
Instead of immediately asking Cursor to edit code, the tutorial uses another planning prompt. The agent is asked to analyze the existing framework and identify which files need to be added or modified. It is explicitly told not to make changes yet.

This two-stage method is extremely useful for agentic coding:
- Ask for the change plan.
- Review the proposed files and approach.
- Only then authorize edits.
The agent proposes changes to the login feature file, login step definitions, and the login page object. It also identifies a constants file as a possible place for an expected error message. The reasoning is consistent with the existing architecture: the feature defines the new behavior, the step definitions connect Gherkin to implementation, the page object exposes the error message or login actions, and a constants file can hold reusable expected text.

This step is more valuable than simply generating a test because it gives the user a chance to catch architecture mistakes before they spread across the repository. If the framework had a rule that all messages belong in a data fixture instead of a constants file, for example, this is the point where the user could correct the plan.
9. Authorize the Change With Clear Boundaries
Once the proposed approach looks reasonable, the creator gives Cursor permission to proceed. The instruction is still constrained: add the invalid login scenario using the existing feature-file, step-definition, page-object, and framework structure, and do not change unrelated functionality.

That wording reflects another strong practice: tell the agent to follow the project’s existing conventions. An AI model can invent many technically valid ways to implement a test, but in a maintained codebase, consistency is often more important than novelty.
Cursor then updates the relevant framework files. The video shows a new unsuccessful-login scenario being added to the feature, additional step definitions for invalid credentials and error validation, page-object support for the error message, and a new invalid-credentials constant.
The creator already knows the framework, so she is able to compare what existed before with what the agent added. That review is essential. The right mental model is not “Cursor wrote it, therefore it is correct.” The safer model is “Cursor made a structured proposal and patch using repository context, and now I can review whether it respects the framework.”
10. Why This Workflow Is Better Than Asking for a Test From Scratch
If you only asked an AI model, “Write a Playwright invalid login test,” you would probably get a plausible standalone example. It might use Playwright Test directly, invent selectors, create a new test file, and ignore your team’s Cucumber conventions entirely.
The workflow in this tutorial avoids that problem because the agent is grounded in the repository before it writes anything. It learns that the project uses feature files, step definitions, page objects, hooks, configuration, and constants. It sees how the existing successful login path is structured. When asked to add the negative path, it can mirror those conventions rather than invent a parallel architecture.

That is the core advantage of a repository-aware coding agent for QA automation: it can operate on the actual framework, not an abstract example of what the framework might look like.
11. Extending the Same Approach to Manual Testing and PRD Analysis
Near the end of the video, the creator points out that Cursor can also be useful for manual-testing work. The suggested workflow is to provide a product requirements document and ask the AI to derive test scenarios and test cases from it, using the PRD as the source of truth.
That is not a special Playwright feature, and it is not a Cursor-specific testing mode. It is a practical use of a coding agent’s context and reasoning capabilities. The same general pattern applies:
- provide the source document;
- state that it is the authoritative reference;
- ask for coverage areas or scenarios first;
- review the proposed coverage;
- then ask for detailed test cases or automation candidates.
For QA teams, this creates an interesting bridge between manual and automated testing. A requirement can be analyzed into scenarios, a subset can be selected for automation, and then Cursor can inspect the existing framework to determine where those automated scenarios belong.
The important part is traceability. If the AI proposes a test that is not supported by the PRD or existing application behavior, the reviewer should challenge it rather than letting generated coverage quietly become a new requirement.
12. What Has Changed Since the Tutorial Was Recorded
AI coding products evolve quickly, so a few details in the recording should be read as a snapshot of the interface rather than permanent product definitions.
Our Cursor AI Review 2026 covers the wider Agent, model, and usage picture.
Cursor is now described as an agent-first workspace across multiple surfaces
The video focuses on the desktop Agent experience and contrasts an agent window with an IDE-style window. Cursor’s current official product pages describe a unified, agent-first workspace and also expose agents through desktop, terminal, and web experiences. The core idea shown in the tutorial remains valid: Agent can search code, edit files, and run commands. The surrounding UI and available surfaces have expanded.
The model list is not fixed
The recording shows Cursor Grok 4.6. Current Cursor documentation still lists Grok 4.6, but also documents a much broader model selection. Model names, defaults, pricing, and routing can change, so readers should choose a model based on current Cursor settings rather than treating the model shown in the video as a requirement for Playwright automation.
Cursor’s download and platform support have evolved
At the time this article was prepared, Cursor’s official download page listed desktop packages for macOS, Windows, and Linux and showed version 3.24 as the latest release. This will naturally change over time, so the durable instruction is simply to install the current build from Cursor’s official download page.
Playwright Test and Cucumber remain separate layers
Playwright’s official documentation describes Playwright Test as its own end-to-end test framework and runner. Cucumber’s documentation separately defines Gherkin, step definitions, and hooks. The repository in this tutorial combines Cucumber BDD structure with Playwright browser automation. That combination is valid, but the exact npm test behavior comes from this project’s scripts, not from Playwright itself.
13. A Safer Prompting Pattern for Test Automation Agents
The video implicitly demonstrates a reusable prompting sequence that is worth adopting for other automation frameworks.
Our Cursor crash course introduces the same review-first habits for everyday coding tasks.
Phase 1: Read-only orientation
Ask the agent to explain the repository and explicitly say not to edit files. Request the project structure, execution flow, test runner, major folders, configuration, and entry points.
Phase 2: Trace one real scenario
Choose a representative scenario such as login, checkout, search, or user creation. Ask the agent to identify every file involved from high-level specification to browser interaction.
Phase 3: Execute before modifying
Ask the agent to run an existing scenario and report what actually happens. This verifies that the agent understands the runner and exposes environmental or configuration issues.
Phase 4: Diagnose the result
If the test does not pass, ask why. Do not immediately ask the agent to “fix everything.” A skipped or commented test requires different judgment from a selector failure, an assertion failure, or a network problem.
Phase 5: Request a change plan
Before authorizing edits, ask which files need to change and why. Keep this stage read-only.
Phase 6: Apply a constrained patch
Tell the agent to follow the existing architecture and avoid unrelated changes. Review the diff before accepting it.
That sequence creates natural checkpoints. It also makes the agent’s work easier to audit because each prompt has a narrower purpose.
14. Practical Guardrails Before You Let Cursor Modify a QA Repository
The tutorial’s “do not modify any files” instruction is a good start, but teams can go further.
First, work on a branch and make sure the repository is clean before asking an agent to edit. That makes it much easier to review exactly what changed.
Second, ask the agent to cite file paths and explain why each file is relevant. A framework explanation is more useful when you can jump directly to the source.
Third, keep the first modification small. Adding one negative login scenario is a better starting task than asking an agent to redesign the entire framework.
Fourth, run targeted tests after the change. If the project supports tags, feature-file filtering, or a single scenario invocation, use the narrowest command that verifies the patch before running the full suite.
Fifth, review selectors, assertions, and shared utilities carefully. AI agents can follow patterns that are already present in the repository, including bad ones. Repository consistency is helpful, but it is not the same as correctness.
Finally, do not treat generated tests as proof of product behavior. Tests encode assumptions. A human still needs to confirm that the expected behavior matches requirements and that the scenario is worth maintaining.
For more advanced repository practices, see our Cursor senior engineer workflows guide.
15. Final Takeaway
The most convincing part of this Cursor and Playwright workflow is not automatic code generation. It is context-aware progression through a real test framework.
Cursor is first used as a codebase reader. It explains the structure of an inherited Playwright and Cucumber project. Then it becomes a trace assistant, following the login flow across feature files, step definitions, page objects, hooks, and configuration. Next it becomes an execution assistant, running the requested scenario and correctly discovering that the test was commented out rather than passed or failed. Only after those steps does it become a coding agent, planning and implementing a new invalid-login scenario in the framework’s existing style.
For test automation engineers, that is a much more realistic picture of where coding agents can help. The value is not that they eliminate framework knowledge. The value is that they can accelerate the work of acquiring that knowledge, checking assumptions, navigating dependencies, running commands, and preparing focused changes.
Used with clear boundaries and human review, Cursor Agent can become a practical companion for onboarding into automation repositories, diagnosing tests, adding coverage, and connecting requirements to implementation. The safer pattern is simple: understand first, execute second, plan third, edit last.
Official References
- Cursor Agent overview: https://cursor.com/docs/agent/overview
- Cursor quickstart: https://cursor.com/docs/get-started/quickstart
- Cursor download page: https://cursor.com/download
- Cursor models and pricing: https://cursor.com/docs/models-and-pricing
- Playwright installation and Playwright Test overview: https://playwright.dev/docs/intro
- Cucumber documentation: https://cucumber.io/docs/
- Cucumber step definitions: https://cucumber.io/docs/cucumber/step-definitions/
- Cucumber hooks and API reference: https://cucumber.io/docs/cucumber/api/
