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 create a new page in the browser.
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.[1]();The newPage() method creates a new tab or page in the browser context.
Fix the error in the code to navigate to a URL.
await page.[1]('https://example.com');
The correct method to navigate to a URL in Playwright is goto() (all lowercase).
Fill both blanks to wait for an element 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 assert the page title contains expected text.
import { test, expect } from '@playwright/test'; test('page title test', async ({ page }) => { await page.goto('https://example.com'); const title = await page.[1](); [2](title).[3]('Example Domain'); });
Use title() to get the page title, then expect(title).toContain() to check the text.
