Traditional automated crawlers lack business context and frequently fail to traverse these workflows correctly. As a result, important parts of the application may remain untested.
To address this gap, ZeroThreat supports Playwright Specs integration. You can use your existing Playwright test suites to execute real business workflows during security scans, providing deeper coverage across conditionally accessible features and complex user flows that automated crawling alone cannot reliably reach.
ZeroThreat supports Playwright projects written in:
Step 1: Navigate to Targets
Go to the Targets section from ZeroThreat dashboard
.png)
Step 2: Select the Target
Click on the
specific target you wish to configure. This will open the Target Configuration settings.
Step 3: Open Playwright Specs
Inside Target Configuration, click on the Playwright Specs section.
.png)
You will see two options to upload or connect your Playwright project. However, Before importing your project, make sure it is prepared to run inside ZeroThreat using the configuration requirements for your project type described below.
If you already have a Playwright project, you can skip this section and continue to Preparing Your Playwright Project for ZeroThreat.
The methods below provide quick ways to create Playwright Specs using the standard JavaScript / TypeScript Playwright tooling.
This is one of the fastest ways to create Playwright Specs by recording browser interactions.
mkdir playwright-specs
cd playwright-specs
npm init -y
npm init playwright@latest
npx playwright codegen https://your-target-url.com
This opens a browser and begins recording your actions. As you interact with the application, Playwright generates the corresponding test steps.
tests folder and save the generated steps into it, for example:mkdir -p tests
tests/login-flow.spec.ts
npx playwright test
For more information, Refer https://playwright.dev/docs/codegen#generate-tests-with-the-playwright-inspector
This method is useful when you want agent-assisted help to create Playwright Specs from scratch. Playwright provides three built-in test agents: planner, generator, and healer. The usual flow is to let the planner explore the app and produce a Markdown test plan, then let the generator turn that plan into Playwright Test files, and finally use the healer to repair failing tests.
1. Create and open an empty project folder.
mkdir playwright-specs
cd playwright-specs
2. Initialize a Node.js project.
npm init -y
3. Create a Playwright project.
npm init playwright@latest
This creates the base Playwright project structure so you can start generating tests.
4. Generate the Playwright agent definitions for VS Code.
npx playwright init-agents --loop=vscode
Playwright recommends regenerating these agent definitions whenever Playwright is updated so the agents pick up new tools and instructions. VS Code version 1.105 or later is required for this agentic experience.
npx playwright init-agents --loop=vscode
5. Create a seed test.
The planner expects a seed test that sets up the environment needed to interact with your app. Playwright states that the planner uses this test to run initialization such as global setup, project dependencies, fixtures, and hooks, and also uses it as an example for generated tests.
Create a simple seed test such as:
import { test } from '@playwright/test';
test('seed', async ({ page }) => {
await page.goto('https://your-app-url.com');
});
Save it as:
tests/seed.spec.ts
6. Ask the planner to create a bounded and precise plan.
The planner explores your app and produces a Markdown test plan for one or more scenarios and user flows. It works best when the request is narrow and explicit. Avoid vague requests like “cover the whole app.” Instead, tell it exactly what flow should be automated, where it starts, what success looks like, and which seed test it should use.
A very basic prompt can be:
Generate a plan for a Playwright spec that logs into the application, opens the billing page, verifies that the invoices table is visible, and logs out. Use tests/seed.spec.ts as the seed test. Keep the plan focused only on this flow.
Bounded, precise planner tasks usually give better results than broad ones.
7. Review the generated Markdown plan.
The planner produces a human-readable Markdown plan under specs/, such as specs/basic-operations.md. Review it before continuing and make sure it matches the exact workflow you want.
8. Pass the approved plan to the generator.
The generator takes the Markdown plan from specs/ and converts it into executable Playwright Test files under tests/. Playwright notes that the generator verifies selectors and assertions live while performing the scenarios.
Your end result should be a clean spec file such as:
tests/billing-flow.spec.ts
9. Run the generated tests.
npx playwright test
Or run only the generated spec:
npx playwright test tests/billing-flow.spec.ts
10. Use the healer if the spec fails.
When a test fails, the healer replays the failing steps, inspects the current UI, suggests a patch such as a locator update or wait adjustment, and reruns the test until it passes or until its guardrails stop the loop.
11. Review the healed result and make manual corrections where needed.
The healer can fix many practical issues, but it should not replace human review. After healing, check whether the final test is still doing exactly what you intended. If selectors, waits, assertions, or flow logic still need adjustment, update the spec manually and run it again.
12. Repeat the same flow for additional user journeys.
This workflow works best when the requested plan is bounded and precise. Smaller, clearly defined flows are easier for the planner to map, easier for the generator to turn into useful specs, and easier for the healer to fix when something breaks. This also aligns with Playwright’s documented flow of planner to generator to healer producing test coverage sequentially.
For more information, Refer https://playwright.dev/docs/test-agents
Once the spec runs successfully, it is ready to be adapted for ZeroThreat by applying the proxy configuration described below.
ZeroThreat can execute both JavaScript / TypeScript and Python Playwright projects.
The required setup differs slightly between the two runtimes.
JavaScript / TypeScript projects require a small Playwright configuration change so browser traffic is routed through the ZeroThreat scanning proxy.
Before importing a JavaScript or TypeScript Playwright project, configure it so browser traffic is routed through the ZeroThreat scanning engine.
At the top of your playwright.config.ts, make sure devices is imported:
import { defineConfig, devices } from '@playwright/test'
In your default Playwright configuration, keep the project running in headless mode. If you already have headless: true set, keep it as it is. Otherwise, do not explicitly add or override this setting.
You should also structure your Playwright project so that each individual spec completes within 30 seconds. This is the timeout used for Playwright Spec execution inside ZeroThreat. You can have as many individual specs as needed, but each spec should stay within that limit to ensure the best coverage.
Inside your playwright.config.ts, add the following project configuration under projects:
{
name: 'ZT-Proxy-Chromium',
use: {
...devices['Desktop Chrome'],
proxy: {
server: 'http://localhost:8000',
},
ignoreHTTPSErrors: true,
},
}
This ensures that Playwright traffic flows through the ZeroThreat scanning engine.
Inside your package.json, add the following script under scripts:
"zt:test": "npx playwright test --project=ZT-Proxy-Chromium"
After these changes, your existing Playwright Specs will automatically execute within ZeroThreat without requiring any modifications to your test spec logic.
Python projects are automatically detected from their dependency files and do not require manual proxy configuration. Expand this section to review project detection, dependency requirements, test execution options, and spec-level reporting.
ZeroThreat also supports Playwright Specs written in Python, including projects using pytest, pytest-playwright, direct Playwright APIs, or custom test runners.
Python Project Detection
Python projects are automatically detected when the selected repository path or uploaded project contains one of the following files:
requirements.txtpyproject.tomluv.lockIf a package.json is present at the same project level, the project is not automatically treated as a Python project.
sync_api and async_api based tests.Dependency Files
Your Python project must contain at least one supported dependency file at the project root or configured repository path:
requirements.txtpyproject.tomluv.lockZeroThreat installs the project dependencies automatically before executing the tests, including the required Playwright browsers.
Choosing How Your Tests Run
ZeroThreat needs to determine which command should execute your test suite.
There are two supported approaches.
Option 1: Standard pytest projects
If your project uses a standard pytest setup, including pytest-playwright fixtures or direct use of sync_playwright(), ZeroThreat automatically detects the project style and executes the tests.
No additional ZeroThreat configuration is required.
Option 2: Custom test command
If your project does not use a standard pytest setup, you can explicitly define the command ZeroThreat should execute.
This can be useful for projects using:
behavetoxnoxpytest commandsAdd a [tool.zerothreat] section to your pyproject.toml:
[tool.zerothreat]
test_command = "python -m pytest -m 'not flaky' --tb=short"
ZeroThreat runs the command exactly as configured inside the project's Python environment, with the scanning proxy already active.
test_command is declared and the project is not recognized as a standard pytest setup, ZeroThreat attempts a default pytest run.test_command is recommended.Getting Spec-Level Reporting
For the best visibility in the Scan Report, your test run should generate a pytest-json-report compatible report.json.
This allows ZeroThreat to associate execution results and network activity with individual specs instead of only recording the overall test run result.
For standard pytest projects, this is handled automatically.
If you use a custom test_command, include:
--json-report --json-report-file=report.json
For example:
[tool.zerothreat]
test_command = "python -m pytest -m 'not flaky' --tb=short --json-report --json-report-file=report.json"
Without this report, ZeroThreat can still determine whether the overall test command passed or failed, but individual spec-level results cannot be displayed.
Python Test Execution Requirements
Python Playwright projects should run their tests serially.
Avoid parallel execution plugins or options such as:
pytest -n auto
Parallel execution may cause network activity generated by one test to be incorrectly attributed to another spec in the Scan Report.
Keep each test focused on a specific workflow and avoid combining several large business flows into a single test.
Regardless of the project language, structure your Playwright Specs so that each individual test completes within 30 seconds.
You can include as many individual specs as required, but every spec should remain within this execution limit.
For the most reliable scan coverage:
Once your Playwright project is prepared, you can add it to ZeroThreat using either GitHub or a ZIP upload.
The same import methods are used for JavaScript / TypeScript and Python projects.
Use this method to connect your existing Playwright GitHub repository directly to ZeroThreat using the ZeroThreat GitHub App.
Follow these steps:
.png)
.png)
.png)
.png)
.png)
The selected path should point to the root of the project ZeroThreat should execute.
For JavaScript / TypeScript projects, this should contain the relevant Playwright project files such as:
package.json
playwright.config.ts
For Python projects, the selected path should contain one of:
requirements.txt
pyproject.toml
uv.lock
If the Python project uses a custom ZeroThreat test command, make sure the corresponding pyproject.toml containing [tool.zerothreat] is available at that path.
.png)
Once connected, your Playwright Specs will be used to improve coverage in future scans.
You can also upload your Playwright project directly.
.zip file of the project containing playwright specsFor a JavaScript / TypeScript project, include the required Node and Playwright configuration files, including:
package.json
playwright.config.ts
For a Python project, include at least one supported dependency file:
requirements.txt
pyproject.toml
uv.lock
If the Python project uses a custom ZeroThreat test command, also ensure that the pyproject.toml containing the [tool.zerothreat] configuration is included.
.png)
Once uploaded, your Playwright Specs will be listed in the Playwright Specs section for that target.
Once Playwright Specs are configured for a target, they will automatically run when you initiate a scan.
After the scan completes:
.png)
.png)
While a scan is running, you can monitor Playwright spec execution progress within the AI-Driven Penetration view.
A dedicated Playwright Spec block will display:
.png)
This allows you to verify that critical workflows using Playwright specs are being tested as expected.
Integrating Playwright Specs provides:
By combining automated crawling with application-specific Playwright workflows, ZeroThreat can explore more of the application's real functionality during a security scan.
Playwright Specs allow you to bring real application workflows into ZeroThreat security scans using your existing automation suites.
ZeroThreat supports Playwright projects written in JavaScript / TypeScript and Python. JavaScript / TypeScript projects require explicit ZeroThreat proxy configuration, while Python projects are automatically routed through the scanning proxy without requiring changes to individual tests.
Projects can be connected through GitHub or uploaded as a ZIP file. Once configured, the specs run automatically during scans, with execution status available during active scans and in the Scan Report.
For the best results, keep specs small, reliable, and focused on meaningful business workflows.