Last active
February 9, 2023 10:50
-
-
Save codegino/42bca1eb2a22e5c19bb61df5fcb1ec22 to your computer and use it in GitHub Desktop.
Playwright - Writing a test
This file contains 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, chromium } from "@playwright/test"; | |
test("get started link long version", async () => { | |
// Open a browser | |
const browser = await chromium.launch(); | |
// Open a new page | |
const context = await browser.newContext(); | |
const page = await context.newPage(); | |
// Navigation | |
await page.goto("https://playwright.dev/"); | |
// Wait for an element to load | |
await expect(page.getByText("Get started")).toBeVisible(); | |
// Locating an element | |
const link = page.getByText("Get started"); | |
// Interaction | |
await link.click(); | |
// Assertion | |
await expect(page).toHaveURL(/.*intro/); | |
}); |
This file contains 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("get started link long version", async ({ page }) => { | |
// Navigation | |
await page.goto("https://playwright.dev/"); | |
// Wait for an element to load | |
await expect(page.getByText("Get started")).toBeVisible(); | |
// Locating an element | |
const link = page.getByText("Get started"); | |
// Interaction | |
await link.click(); | |
// Assertion | |
await expect(page).toHaveURL(/.*intro/); | |
}); |
This file contains 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("get started link long version", async ({ page }) => { | |
// Navigation | |
await page.goto("https://playwright.dev/"); | |
// Locating an element + Interaction | |
await page.getByText("Get started").click(); | |
// Assertion | |
await expect(page).toHaveURL(/.*intro/); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment