Last active
September 25, 2023 02:54
-
-
Save nadvolod/3921a0bf24af252812e7f61036b1b96b to your computer and use it in GitHub Desktop.
Playwright test running in Azure DevOps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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