What is Playwright?

Playwright is a modern automation testing framework developed by Microsoft. It is mainly used for automating and testing web applications.

Playwright allows testers and developers to perform testing on multiple browsers using a single API.

Why is Playwright popular?

Playwright has become popular because of its modern features and reliable execution.

1. Cross-Browser Testing

Playwright supports multiple browsers with the same test script.

2. Fast Execution

Tests execute quickly compared to many traditional automation tools.

3. Parallel Execution

Multiple test cases can run simultaneously, reducing execution time.

4. Auto-Wait Mechanism

Playwright automatically waits for elements before performing actions.

5. Headless Execution

Tests can run without opening the browser UI, improving performance.

6. Multiple Language Support

Playwright supports:

  • JavaScript
  • TypeScript
  • Java
  • Python
  • C#
7. Reliable Testing

Playwright provides stable and consistent test execution for modern applications.

Advantages of Playwright

  • Easy to learn
  • Faster execution
  • Better handling of dynamic elements
  • Supports modern web applications
  • Built-in reporting and debugging features
import { test, expect } from '@playwright/test';


test('My Test case 1', async ({ page }) => {

    await page.goto("https://logicnextgen.com/projects/logiccart/upload/");
    await page.waitForTimeout(20000);

});
import { test, expect, Locator } from '@playwright/test';

test('Text Box', async ({ page }) => {

    // Open URL
    await page.goto("https://logicnextgen.com/projects/AutomationTestingPractice/textbox.php");

    // Full Name
    const fullName: Locator = page.locator('#fullname');
    await fullName.fill('Keshav Kapoor');

    // Email
    const email: Locator = page.locator('#email');
    await email.fill('Keshav@gmail.com');

    // Current Address
    const address: Locator = page.locator('#address');
    await address.fill('Delhi, India');

    // Password
    const password: Locator = page.locator('#password');
    await password.fill('Keshav@123');

    // Wait
    await page.waitForTimeout(20000);

});
import { test, expect, Locator } from '@playwright/test';

test('Radio Button', async ({ page }) => {

    // Open URL
    await page.goto("https://logicnextgen.com/projects/AutomationTestingPractice/Radiobutton.php");

    // Select Male radio button
    const male: Locator = page.locator('#male');
    await male.check();

    // Wait for 5 seconds
    await page.waitForTimeout(5000);

    // Select Female radio button
    const female: Locator = page.locator('#female');
    await female.check();

    // Wait for 20 seconds
    await page.waitForTimeout(20000);

});
import { test, expect, Locator } from '@playwright/test';

test('Check Box', async ({ page }) => {

    // Open URL
    await page.goto("https://logicnextgen.com/projects/AutomationTestingPractice/checkbox.php");

    // Select Mumbai checkbox
    const mumbai: Locator = page.locator('#mumbai');
    await mumbai.check();

    // Wait
    await page.waitForTimeout(3000);

    // Select Delhi checkbox
    const delhi: Locator = page.locator('#delhi');
    await delhi.check();

    // Wait
    await page.waitForTimeout(3000);

    // Select Noida checkbox
    const noida: Locator = page.locator('#noida');
    await noida.check();

    // Final Wait
    await page.waitForTimeout(20000);

});