Playwright
Integrate Playwright (TypeScript) with AgentQ AI for AI-driven automation and automated reporting.

Installation & Usage
Setup from scratch (sample project)
- Clone the repository:
git clone https://github.com/agentq-ai/playwright_typescript.git- Install dependencies:
npm install- Install AgentQ package:
npm install agentq-playwright- Configure your API key in
agentq.config.json(this is the same company API key from your account profile, also used asAGENTQ_API_KEYbelow):
{
"TOKEN": "YOUR_API_KEY"
}Or export it:
export AGENTQ_TOKEN="YOUR_API_KEY"Integration into your existing project
- Install the AgentQ library:
npm install agentq-playwright- Create
agentq.config.jsonin your project root:
{
"TOKEN": "YOUR_API_KEY"
}- Set up environment variables in a
.envfile:
AGENTQ_API_KEY=your_api_key # same API key as TOKEN in agentq.config.json
AGENTQ_PROJECT_ID=your_project_id
AGENTQ_TESTRUN_ID=your_testrun_id
AGENTQ_EMAIL=your_email # optional: results show this member as "Created By" (owner or invited member of the key's company)With AGENTQ_API_KEY set, no password is needed — test results, screenshots, and videos are pushed to your test run using the API key directly. Add AGENTQ_EMAIL (any member of your company — owner or invited) if you want pushed results attributed to that person instead of the API key.
Results are matched by the numeric prefix of each test title (e.g.
12-Login successupdates test case12). Specs pulled with the CLI tools below already follow this convention; keep the prefix if you write specs by hand.
Legacy fallback: if
AGENTQ_API_KEYis not set, the library falls back toAGENTQ_EMAILandAGENTQ_PASSWORDlogin.
Tip for CI (e.g. GitHub Actions): store
AGENTQ_API_KEYas a secret and export it in the workflow — API key auth skips the login endpoint entirely.
Usage Examples
Non-POM (Page Object Model)
import { q, test } from 'agentq-playwright';
import { expect } from '@playwright/test';
test.describe('Login', () => {
test('login success', async ({ page }) => {
await page.goto('https://www.saucedemo.com/');
await q('user fill "username" field with "standard_user"');
await q('user fill "password" field with "standard_user"');
await q('User click "login" button');
});
});POM (Page Object Model)
login.page.ts
import { q } from 'agentq-playwright';
import { type Locator, type Page } from '@playwright/test';
export class LoginPage {
readonly page: Page;
readonly error_text: Locator;
constructor(page: Page) {
this.page = page;
this.error_text = page.locator('[data-test="error"]')
}
async doLogin() {
await q('User fill "username" field with "standard_user"');
await q('User fill "password" field with "standard_user"');
await q('User click "login" button');
}
}login_fail.spec.ts
import { test } from "agentq-playwright";
import { expect } from "@playwright/test";
import { LoginPage } from '../pages/login.page';
test.describe('Login', () => {
test('login failed', async ({ page }) => {
const loginpage = new LoginPage(page);
await page.goto('https://www.saucedemo.com');
await loginpage.doLogin();
await expect(loginpage.error_text).toBeVisible();
});
});Running Tests
Run with environment variables:
npm run test
# or
npx playwright testCLI Tools
Pull test cases or suites directly into your project:
npx agentq-pull-testcase -- --tcid=YOUR_TC_ID # e.g. --tcid=1
npx agentq-pull-testsuite -- --testrunid=YOUR_TESTRUN_ID # e.g. --testrunid=57e67dc7-c54d-42bc-a90d-409add62accePlans and Rate Limits
For details on Free or Enterprise plans, visit www.agentq.id or contact support@agentq.id.
