|
| 1 | +const { expect, test } = require('@playwright/test'); |
| 2 | + |
| 3 | +test('Browserstack playwright demo', async ({ page }) => { |
| 4 | + const baseUrl = 'https://the-internet.herokuapp.com/'; |
| 5 | + |
| 6 | + await page.goto(baseUrl); |
| 7 | + |
| 8 | + await page.waitForTimeout(3000); |
| 9 | + |
| 10 | + await expect(page).toHaveTitle('The Internet'); |
| 11 | + |
| 12 | + await page.getByRole('link', { name: 'Checkboxes' }).click(); |
| 13 | + |
| 14 | + const checkbox1 = page.getByRole('checkbox').first(); |
| 15 | + const checkbox2 = page.getByRole('checkbox').last(); |
| 16 | + |
| 17 | + expect(await checkbox1.isChecked()).toBe(false); |
| 18 | + await checkbox1.check(); |
| 19 | + expect(await checkbox1.isChecked()).toBe(true); |
| 20 | + |
| 21 | + expect(await checkbox2.isChecked()).toBe(true); |
| 22 | + await checkbox2.uncheck(); |
| 23 | + expect(await checkbox2.isChecked()).toBe(false); |
| 24 | + |
| 25 | + await page.goto(baseUrl); |
| 26 | + await page.getByRole('link', { name: 'Dropdown' }).click(); |
| 27 | + |
| 28 | + const dropdown = page.locator('#dropdown'); |
| 29 | + await dropdown.selectOption({ label: 'Option 1' }); |
| 30 | + |
| 31 | + await page.goBack(); |
| 32 | + |
| 33 | + const availableExamples = page.getByRole('heading', { name: 'Available Examples' }); |
| 34 | + const headingText = await availableExamples.textContent(); |
| 35 | + expect(headingText).toContain('Available Examples'); |
| 36 | +}); |
0 commit comments