Have a question?
Message sent Close
View Categories

Validate Page Title and URL

📄
PageTitleURL.spec.ts
// Import Playwright test and expect assertion library
import { test, expect } from '@playwright/test';

// Define a test case with title
test('Validate Page Title and URL', async ({ page }) => {

  // Step 1: Navigate to the website
  await page.goto('https://vinothqaacademy.com/');

  // Step 2: Get the actual page title
  const actualTitle = await page.title();
  console.log('Page Title:', actualTitle); // For debugging

  // Step 3: Validate (assert) the page title
  await expect(page).toHaveTitle('Vinoth Tech Solutions – Empowering Tech Careers');

  // Negative scenario example (kept commented):
  // await expect(page).toHaveTitle('Vinoth Tech Solutions – Empowering Tech Career')

  // Step 4: Get the actual page URL
  const actualURL = page.url();
  console.log('Page URL:', actualURL); // For debugging

  // Step 5: Validate (assert) the page URL
  await expect(page).toHaveURL('https://vinothqaacademy.com/');
});