agentq-playwright
v1.0.69
Published
Sample integrate Playwright (typescript) with AgentQ AI.
Readme
AgentQ for Playwright
Sample integrate Playwright (typescript) with AgentQ AI.
Installation & Usage
Setup & run from scratch (if you need start from sample)
- clone this repository
git clone https://github.com/agentq-ai/playwright_typescript.git- install node modules
npm install- Install AgentQ package for Playwright using npm (applicable using yarn as well)
npm install agentq-playwright- Update apiKey on json file
agentq.config.jsonbased on your account profile (you must signin first)
export TOKEN="apiKey"- Run your test
npm run testor
npx playwright testSetup & run from your own Playwright
- Install AgentQ package for Playwright using npm (applicable using yarn as well)
npm install agentq-playwright- Create json file
agentq.config.jsonbased on your account profile (you must signin first)
{
"TOKEN": "apiKey"
}- Below is sample usage q() funciton (using POM and non-POM)
non-POM
- login.spec.ts
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
- login.page.ts on pages file
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();
});
});Test Run Sync (pull test suite & push results)
Pull a test suite from a test run and automatically report each test's status (passed/failed) back to AgentQ.
- Set your credentials as environment variables (or in
.env). The recommended way is a company API key — no email/password needed:
AGENTQ_API_KEY=your_company_api_key # from your AgentQ profile
AGENTQ_PROJECT_ID=your_project_id
AGENTQ_TESTRUN_ID=your_testrun_id
AGENTQ_EMAIL=your_email # optional: results show this company member as "Created By"Email/password login is still supported as a fallback (when no API key is set):
AGENTQ_EMAIL=your_email
AGENTQ_PASSWORD=your_password- Pull the test suite for a test run:
npx agentq-pull-testsuite -- --testrunid=YOUR_TESTRUN_ID- Run the generated spec with Playwright. Results (passed/failed, execution time, screenshots, videos) are pushed back to the test run automatically:
npx playwright testTip 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.
Plans and Rate Limits
- Free: Free of charge
- Pro & Enterprise : visit www.agentq.id or contact [email protected] to upgrade your plan.
