Skip to content

Instantly share code, notes, and snippets.

@nadvolod
Last active September 25, 2023 02:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nadvolod/3921a0bf24af252812e7f61036b1b96b to your computer and use it in GitHub Desktop.
Save nadvolod/3921a0bf24af252812e7f61036b1b96b to your computer and use it in GitHub Desktop.
Playwright test running in Azure DevOps
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
inputs:
versionSpec: '14.x'
displayName: 'Install Node.js'
- script: |
npm install
npx playwright install --with-deps
displayName: 'npm install'
workingDirectory: 'ts/playwright'
# need to orun xvbf for playwright automation
- script: |
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test.sanity
displayName: 'Framework Sanity Tests'
workingDirectory: 'ts/playwright'
import { test, expect } from '@playwright/test';
test('homepage has Playwright in title and get started link linking to the intro page', async ({ page }) => {
await page.goto('https://playwright.dev/');
// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Playwright/);
// create a locator
const getStarted = page.locator('text=Get Started');
// Expect an attribute "to be strictly equal" to the value.
await expect(getStarted).toHaveAttribute('href', '/docs/intro');
// Click the get started link.
await getStarted.click();
// Expects the URL to contain intro.
await expect(page).toHaveURL(/.*intro/);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment