Challenge - 5 Problems
Playwright E2E Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the test result of this Playwright code snippet?
Consider this Playwright test for a Svelte app login page. What will be the test execution result?
Svelte
import { test, expect } from '@playwright/test'; test('login button is enabled after input', async ({ page }) => { await page.goto('http://localhost:5173/login'); await page.fill('input[name="username"]', 'user1'); await page.fill('input[name="password"]', 'pass123'); const isEnabled = await page.isEnabled('button#login-btn'); expect(isEnabled).toBe(true); });
Attempts:
2 left
💡 Hint
Think about how Playwright interacts with form inputs and button states.
✗ Incorrect
The test navigates to the login page, fills username and password inputs, then checks if the login button is enabled. The selector 'button#login-btn' is valid, and filling inputs enables the button, so the test passes.
❓ locator
intermediate1:30remaining
Which locator correctly selects the submit button in a Svelte form?
You want to select the submit button in a Svelte form for Playwright testing. The button has class 'submit-btn' and text 'Submit'. Which locator is best?
Attempts:
2 left
💡 Hint
Combine class and visible text for precise selection.
✗ Incorrect
Option A combines the class selector and the visible text filter, ensuring the locator matches the button with class 'submit-btn' and text 'Submit'. This is the most precise and reliable locator.
❓ assertion
advanced1:30remaining
What assertion verifies a success message is visible after form submission?
After submitting a form, a success message with id 'success-msg' should appear. Which assertion correctly verifies this in Playwright?
Attempts:
2 left
💡 Hint
Check for visibility explicitly.
✗ Incorrect
Option A uses toBeVisible() which directly checks if the element is visible on the page. Other options check text content but do not guarantee visibility.
🔧 Debug
advanced2:00remaining
Why does this Playwright test fail with a timeout error?
This test fails with a timeout error. What is the most likely cause?
Code:
import { test, expect } from '@playwright/test';
test('check welcome text', async ({ page }) => {
await page.goto('http://localhost:5173/home');
await expect(page.locator('text=Welcome')).toBeVisible({ timeout: 1000 });
});
Attempts:
2 left
💡 Hint
Consider the timeout duration and page content loading.
✗ Incorrect
The test waits only 1 second for the 'Welcome' text to appear. If the page or element loads slower, the test times out. The locator syntax and await usage are correct.
❓ framework
expert3:00remaining
How to implement a reusable Playwright test fixture for authenticated Svelte app sessions?
You want to create a Playwright fixture that logs in once and reuses the authenticated session for multiple tests in a Svelte app. Which approach is correct?
Attempts:
2 left
💡 Hint
Think about session reuse and test speed optimization.
✗ Incorrect
Using test.extend to create a fixture that logs in once and saves the storageState allows reusing the authenticated session, speeding up tests and avoiding repeated logins.