Search
  • +44-7459919437 (UK- WhatsApp & Direct Call) | +91-6383544892 (India - WhatsApp Only) | Email Id : vinothrwins@gmail.com
Vinoth Tech Solutions
  • Home
  • Selenium Java Online Training
  • Self Paced Video Course
    • Selenium Course Curriculum
    • Cypress Course Curriculum
    • Playwright Course Curriculum
  • Tutorials
  • Demo Sites
    • E-Commerce Demo Application
    • Practice Automation
      • Demo Page Healthcare
      • Registration Form
      • Transaction Details
      • DropDown
      • Mouse Event
      • Keyboard Events
      • Alert and Popup
      • Multiple Windows
      • iFrames
      • Wait WebElement
      • WebTable
  • FAQS
  • About Me & Feedback
    • Placed Students Feedback
    • Online Training Feedback
    • LinkedIn Profile
    • TechTalk
  • Free YouTube Courses
    • Python for Automation
    • Free QA Video Courses
      • Manual Testing
      • Java For Automation
      • Selenium Webdriver
      • TestNG
      • Cucumber BDD
      • UFT(QTP) Automation
    • Free Data Science Courses
      • Artificial Intelligence for Beginners
      • Python For A.I
      • Python Pandas
      • Python NumPy
      • Mathematics for A.I
  • Home
  • Selenium Java Online Training
  • Self Paced Video Course
    • Selenium Course Curriculum
    • Cypress Course Curriculum
    • Playwright Course Curriculum
  • Tutorials
  • Demo Sites
    • E-Commerce Demo Application
    • Practice Automation
      • Demo Page Healthcare
      • Registration Form
      • Transaction Details
      • DropDown
      • Mouse Event
      • Keyboard Events
      • Alert and Popup
      • Multiple Windows
      • iFrames
      • Wait WebElement
      • WebTable
  • FAQS
  • About Me & Feedback
    • Placed Students Feedback
    • Online Training Feedback
    • LinkedIn Profile
    • TechTalk
  • Free YouTube Courses
    • Python for Automation
    • Free QA Video Courses
      • Manual Testing
      • Java For Automation
      • Selenium Webdriver
      • TestNG
      • Cucumber BDD
      • UFT(QTP) Automation
    • Free Data Science Courses
      • Artificial Intelligence for Beginners
      • Python For A.I
      • Python Pandas
      • Python NumPy
      • Mathematics for A.I

Playwright

  • Handle Browser Navigation
  • Playwright Core Concepts
  • First Playwright Program
  • Step-by-Step Node.js Installation on Windows
  • Step-by-Step VS Code Installation on Windows
  • Step-by-Step Playwright Installation on Windows
  • Playwright VS Code extension Installation and Execution
  • Playwright Folder Structure
View Categories
  • Home
  • Tutorials
  • Playwright
  • Playwright
  • First Playwright Program

First Playwright Program

First Playwright Program

Let’s write our very first Playwright test case to launch an application.

Code Example

📄
PlaywrightFirstProgram.spec.ts
// Import Playwright test library
import { test } from '@playwright/test';

// Define a test case with title
test('Launch Application', async ({ page }) => {

  // Step 1: Navigate to the application URL
  await page.goto('https://vinothqaacademy.com/demo-site/');

  // Step 2: Wait for 3 seconds (just to see the page launch during demo)
  await page.waitForTimeout(3000);

  // Step 3: Close the page (browser context auto-closes after test)
  
});

Explanation

- import { test } from '@playwright/test' → imports Playwright’s built-in test runner.

– test('Launch Application', async ({ page }) => { ... }) → defines a test case with the name Launch Application.

– page.goto(URL) → opens the browser and navigates to the given application URL.

– page.waitForTimeout(3000) → makes the browser wait for 3 seconds (just for demo purposes).

– Browser context and page auto-close after the test run, no need to close manually.

Behind the Scenes

– Playwright automatically launches a browser context for each test.

– All Playwright functions are asynchronous, which is why we use async/await to run steps in order.

– waitForTimeout() is used here only for demo. In real automation, prefer auto-waiting or waitForSelector() for stability.

What You’ll See

– A browser window opens.

– The demo site loads.

– The page stays open for 3 seconds.

– The browser closes automatically.

Try It Yourself

– Change the URL to https://playwright.dev/ and rerun the test.

– Modify the timeout value (e.g., 1000 ms = 1 second).

– Remove waitForTimeout() and notice how quickly the test finishes

Playwright Tutorials
What are your Feelings

Share This Article :

  • Facebook
  • X
  • LinkedIn
Playwright Core ConceptsStep-by-Step Node.js Installation on Windows
© 2018 – 2025 Vinoth Tech Solutions Ltd (UK), Reg. No: 16489105