TargetQA
TypeScript
Lesson 1 of 4 · 5 min

1.1 Writing Your First Playwright Test

AI

Lesson Audio Narration

### What is Playwright? Playwright is a modern framework for reliable end-to-end testing across Chromium, Firefox, and WebKit with a single API. Unlike older tools, Playwright communicates directly with browser developer protocols, enabling **instant execution**, **automatic waiting**, and **isolated browser contexts**. ### Basic Anatomy of a Playwright Test ```typescript import { test, expect } from '@playwright/test'; test('verify application landing page', async ({ page }) => { // 1. Navigate to target URL await page.goto('https://targetqa.com'); // 2. Assert page title await expect(page).toHaveTitle(/TargetQA/); }); ``` #### Key Concepts to Remember: 1. **`test(name, async ({ page }) => { ... })`**: The entrypoint for every test case. 2. **`page` fixture**: An isolated browser tab created automatically for each test with zero shared state. 3. **`await` keyword**: Web browser operations are asynchronous. Every action (`goto`, `click`, `fill`) must be awaited.
Your Task

Navigate to `'https://targetqa.com'` using `await page.goto(...)` and verify that the page title contains `'TargetQA'` using `await expect(page).toHaveTitle(...)`.

Common doubts
Did you find this lesson helpful?
solution.ts
Loading code editor…
Execution Console

Click "Run Code" to test your implementation.