Skip to content

Playwright

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

AgentQ Playwright Integration

Installation & Usage

Setup from scratch (sample project)

  1. Clone the repository:
bash
git clone https://github.com/agentq-ai/playwright_typescript.git
  1. Install dependencies:
bash
npm install
  1. Install AgentQ package:
bash
npm install agentq-playwright
  1. Configure your API key in agentq.config.json:
json
{
  "TOKEN": "YOUR_API_KEY"
}

Or export it:

bash
export TOKEN="YOUR_API_KEY"

Integration into your existing project

  1. Install the AgentQ library:
bash
npm install agentq-playwright
  1. Create agentq.config.json in your project root:
json
{
  "TOKEN": "YOUR_API_KEY"
}
  1. Set up environment variables in a .env file:
bash
AGENTQ_PROJECT_ID=your_project_id
AGENTQ_TESTRUN_ID=your_testrun_id
AGENTQ_EMAIL=your_email
AGENTQ_PASSWORD=your_password

Usage Examples

Non-POM (Page Object Model)

typescript
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

typescript
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

typescript
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:

bash
npm run test
# or
npx playwright test

CLI Tools

Pull test cases or suites directly into your project:

bash
npx agentq-pull-testcase -- --tcid=YOUR_TESTRUN_ID{{1}}       
npx agentq-pull-testsuite -- --testrunid=YOUR_TESTRUN_ID{{57e67dc7-c54d-42bc-a90d-409add62acce}}

Plans and Rate Limits

For details on Free or Enterprise plans, visit www.agentq.id or contact [email protected].

Released under the MIT License.