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 a URL in Playwright.
const page = await browser.newPage(); await page.[1]('https://example.com');
The correct method to navigate to a URL is goto() in Playwright.
Fix the error in the assertion to check page title.
const title = await page.title(); expect(title).[1]('Welcome');
The Playwright test assertion uses toBe() to check equality.
Fill both blanks to wait for a button and click it.
await page.[1]('button#submit'); await page.[2]('button#submit');
First, waitForSelector() waits for the button to appear, then click() clicks it.
Fill all three blanks to create a test that opens a page, fills a form, and submits it.
test('submit form', async ({ page }) => { await page.[1]('https://example.com/form'); await page.fill('[2]', 'John Doe'); await page.[3]('button[type=submit]'); });
The test navigates with goto, fills the input with selector #name, then clicks the submit button with click.
