Playwright
  • Introduction
    • Playwright With TS
  • Automation the right things with Playwright
  • Setup
    • Setting Up Your Environment
    • Typescript fundamental
    • Setup Playwright TS Project in VS code
    • Record and Playback with Code Generation using VS Code Playwright Extension
    • Record and Playback using Playwright Codegen with Inspector
  • Playwright config file
  • Implement Test Cases
    • Open Browser
    • Fake Geolocation
    • Form Authentication
    • Checkboxes
    • Dropdown
    • Hyperlink
    • Web Table
    • Drag Drop
    • Frame
    • Horizontal Slide
    • Context Click - Right Click
  • Hover
  • Take Screenshot
  • Automatic screenshots on failure:
  • Page Object Model
    • Understanding the Page Object Model pattern
  • Implementing POM with Login Page
  • Combine POM with Playwright Fixture
  • API Testing
    • API Docs
  • GET
  • API POST
  • PUT
  • DELETE
  • CI/CD And Reporting
    • Setup Allure Report
    • Run in Github Actions
  • Playwright & AI
    • Debug & Generate Playwright Tests with AI
Powered by GitBook
On this page
  1. Implement Test Cases

Fake Geolocation

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

test.use({
  geolocation: { longitude: 41.890221, latitude: 12.492348 },
  permissions: ['geolocation'],
});

test('my test with geolocation', async ({ page }) => {
  page.goto("https://the-internet.herokuapp.com/geolocation")
  page.getByRole('button', { name: 'Where am I?' }).click()
  
  const lat = await page.locator('#lat-value').textContent()
  const long = await page.locator('#long-value').textContent()
  
  expect(lat).toBe('12.492348')
  expect(long).toBe('41.890221')
});
PreviousOpen BrowserNextForm Authentication

Last updated 15 days ago