QAplanetLogin

QAplanet

Code Generation

Generate Playwright TypeScript or Python automation for selected automatable test cases using environment placeholders and accessible locator guidance.

Selected Automatable Cases

0 ready

No selected automatable cases

Select automatable test cases before generating scripts.

Saved Scripts

customer-login.spec.ts

Playwright TypeScript

import { test, expect } from "@playwright/test";

const appUrl = process.env.PLAYWRIGHT_BASE_URL ?? "http://localhost:3000";
const customerEmail = process.env.TEST_CUSTOMER_EMAIL;
const customerPassword = process.env.TEST_CUSTOMER_PASSWORD;
const invalidEmail = process.env.TEST_INVALID_EMAIL;
const invalidPassword = process.env.TEST_INVALID_PASSWORD;

test.describe("Customer authentication", () => {
  test("QA-TC-001 customer logs in with valid credentials", async ({ page }) => {
    test.skip(!customerEmail || !customerPassword, "Set TEST_CUSTOMER_EMAIL and TEST_CUSTOMER_PASSWORD.");

    await page.goto(`${appUrl}/login`);
    await page.getByLabel("Email").fill(customerEmail!);
    await page.getByLabel("Password").fill(customerPassword!);
    await page.getByRole("button", { name: /sign in/i }).click();

    await expect(page.getByRole("heading", { name: /dashboard/i })).toBeVisible();
  });

  test("QA-TC-002 invalid login displays clear error", async ({ page }) => {
    test.skip(!invalidEmail || !invalidPassword, "Set TEST_INVALID_EMAIL and TEST_INVALID_PASSWORD.");

    await page.goto(`${appUrl}/login`);
    await page.getByLabel("Email").fill(invalidEmail!);
    await page.getByLabel("Password").fill(invalidPassword!);
    await page.getByRole("button", { name: /sign in/i }).click();

    await expect(page.getByText(/invalid|incorrect|unable to sign in/i)).toBeVisible();
  });
});