Complete the code to launch a browser in Playwright.
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.[1]();
await browser.close();
})();The launch method starts a new browser instance in Playwright.
Complete the code to navigate to the homepage URL in Playwright.
const page = await browser.newPage(); await page.[1]('http://localhost:3000');
The correct method to navigate to a URL in Playwright is goto (all lowercase).
Fix the error in the assertion to check the page title.
const title = await page.title(); expect(title).[1]('My Next.js App');
Playwright uses Jest-like assertions where toBe checks exact equality.
Fill both blanks to select a button by its role and click it.
await page.getBy[1]('button', { name: '[2]' }).click();
Use getByRole to select elements by role, and name matches the button text.
Fill all three blanks to write a test that launches browser, opens page, and checks title.
test('homepage has correct title', async () => { const browser = await [1].launch(); const page = await browser.[2](); await page.goto('http://localhost:3000'); const title = await page.title(); expect(title).[3]('Welcome to Next.js!'); await browser.close(); });
This test uses chromium.launch() to start the browser, newPage() to open a tab, and toBe to assert the title.
