Latest playwright Interview Questions and Answers 2026 for Freshers and Experienced


Home->Playwright Interview Questions and Answers

If you're looking for current Playwright interview questions and answers, you've come to the right place! This Latest 2026 Question List will provide you with a comprehensive list of trending Playwright interview questions and answers asked in Top Companies interview round.

Playwright Interview Questions and Answers Play Quiz On Playwright  |  More Q&A Click Here

# Question Options Answer
1 What is Playwright?
  • A JavaScript library for building UI components
  • A cross-browser automation framework by Microsoft
  • A performance monitoring tool
  • A cloud-based CI/CD platform
  • A cross-browser automation framework by Microsoft
    2 Which browsers are supported by Playwright?
  • Only Chrome and Firefox
  • Chrome, Safari, and Edge
  • Chromium, Firefox, and WebKit
  • Internet Explorer and Opera
  • Chromium, Firefox, and WebKit
    3 Which programming languages does Playwright support?
  • JavaScript and TypeScript only
  • Java, Python, C#, and JavaScript/TypeScript
  • PHP and Ruby only
  • Kotlin and Swift only
  • Java, Python, C#, and JavaScript/TypeScript
    4 How does Playwright handle dynamic elements?
  • By using implicit waits only
  • By retrying failed locators automatically
  • By auto-waiting for elements to be ready before actions
  • By requiring manual sleep statements
  • By auto-waiting for elements to be ready before actions
    5 Which of the following is true about Playwright architecture?
  • It uses WebDriver protocol
  • It communicates directly with browser engines
  • It requires third-party drivers for execution
  • It only runs in cloud environments
  • It communicates directly with browser engines
    6 How do you launch a browser in Playwright?
  • const browser = await playwright.launch()
  • const browser = await playwright.chromium.launch()
  • const browser = new Browser()
  • const browser = playwright.openBrowser()
  • const browser = await playwright.chromium.launch()
    7 How do you open a new page in Playwright?
  • const page = await browser.page()
  • const page = await browser.newPage()
  • const page = playwright.createPage()
  • const page = await browser.open()
  • const page = await browser.newPage()
    8 How do you navigate to a URL in Playwright?
  • await page.navigate('https://example.com')
  • await page.goto('https://example.com')
  • await page.open('https://example.com')
  • await browser.goto('https://example.com')
  • await page.goto('https://example.com')
    9 How do you take a screenshot in Playwright?
  • await page.capture('screenshot.png')
  • await page.screenshot({ path: 'screenshot.png' })
  • await browser.screenshot('screenshot.png')
  • await page.saveScreenshot('screenshot.png')
  • await page.screenshot({ path: 'screenshot.png' })
    10 How do you click an element in Playwright?
  • await page.tap('selector')
  • await page.click('selector')
  • await page.press('selector')
  • await page.select('selector')
  • await page.click('selector')
    11 How do you type into an input field in Playwright?
  • await page.type('selector', 'text')
  • await page.input('selector', 'text')
  • await page.sendKeys('selector', 'text')
  • await page.fill('selector', 'text')
  • await page.fill('selector', 'text')
    12 How do you wait for an element to be visible in Playwright?
  • await page.waitForSelector('selector')
  • await page.waitForElement('selector')
  • await page.wait('selector')
  • await page.find('selector')
  • await page.waitForSelector('selector')
    13 How do you get the text content of an element in Playwright?
  • const text = await page.innerText('selector')
  • const text = await page.getText('selector')
  • const text = await page.value('selector')
  • const text = await page.textContent('selector')
  • const text = await page.textContent('selector')
    14 How do you emulate a mobile device in Playwright?
  • await page.emulateDevice('iPhone 11')
  • await page.emulate(devices['iPhone 11'])
  • await page.setDevice('iPhone 11')
  • await browser.mobile('iPhone 11')
  • await page.emulate(devices['iPhone 11'])
    15 How do you handle file uploads in Playwright?
  • await page.uploadFile('selector', 'path/to/file')
  • await page.attachFile('selector', 'path/to/file')
  • await page.setInputFiles('input[type="file"]', 'path/to/file')
  • await page.fileUpload('selector', 'path/to/file')
  • await page.setInputFiles('input[type="file"]', 'path/to/file')
    16 How do you handle alerts in Playwright?
  • page.on('alert', alert => alert.accept())
  • page.on('dialog', dialog => dialog.accept())
  • page.on('popup', popup => popup.dismiss())
  • page.on('message', msg => msg.accept())
  • page.on('dialog', dialog => dialog.accept())
    17 How do you simulate a drag-and-drop action in Playwright?
  • await page.drag('source', 'target')
  • await page.drop('source', 'target')
  • await page.moveElement('source', 'target')
  • await page.dragAndDrop('source', 'target')
  • await page.dragAndDrop('source', 'target')
    18 How do you check if an element is visible in Playwright?
  • const visible = await page.isVisible('selector')
  • const visible = await page.isDisplayed('selector')
  • const visible = await page.exists('selector')
  • const visible = await page.show('selector')
  • const visible = await page.isVisible('selector')
    19 How do you select an option from a dropdown in Playwright?
  • await page.chooseOption('selector', 'value')
  • await page.selectOption('selector', 'value')
  • await page.pick('selector', 'value')
  • await page.option('selector', 'value')
  • await page.selectOption('selector', 'value')
    20 How do you capture a PDF of a page in Playwright?
  • await page.savePDF('page.pdf')
  • await browser.pdf('page.pdf')
  • await page.pdf({ path: 'page.pdf' })
  • await page.exportPDF('page.pdf')
  • await page.pdf({ path: 'page.pdf' })
    21 How do you handle authentication in Playwright?
  • await page.authenticate({ username: 'user', password: 'pass' })
  • await page.login('user','pass')
  • await browser.authenticate('user','pass')
  • await page.setAuth('user','pass')
  • await page.authenticate({ username: 'user', password: 'pass' })
    22 How do you get the HTML of an element in Playwright?
  • const html = await page.outerHTML('selector')
  • const html = await page.innerHTML('selector')
  • const html = await page.getHTML('selector')
  • const html = await page.html('selector')
  • const html = await page.innerHTML('selector')
    23 How do you handle iframes in Playwright?
  • const frame = await page.frame({ name: 'frameName' })
  • const frame = await page.getFrame('frameName')
  • const frame = await browser.frame('frameName')
  • const frame = await page.switchFrame('frameName')
  • const frame = await page.frame({ name: 'frameName' })
    24 How do you listen to console messages in Playwright?
  • page.on('console', msg => console.log(msg.text()))
  • page.on('log', msg => console.log(msg.text()))
  • page.on('message', msg => console.log(msg.text()))
  • page.on('debug', msg => console.log(msg.text()))
  • page.on('console', msg => console.log(msg.text()))
    25 How do you capture video of a test run in Playwright?
  • await page.recordVideo('videos/')
  • await browser.captureVideo('videos/')
  • await page.video('videos/')
  • await context.newPage({ recordVideo: { dir: 'videos/' } })
  • await context.newPage({ recordVideo: { dir: 'videos/' } })
    26 How do you assert that an element has specific text in Playwright?
  • await page.assertText('selector','text')
  • await expect(page.locator('selector')).textEquals('text')
  • await expect(page.locator('selector')).toHaveText('text')
  • await page.verifyText('selector','text')
  • await expect(page.locator('selector')).toHaveText('text')
    27 How do you wait for a network response in Playwright?
  • await page.waitForResponse('**/api')
  • await page.waitForNetwork('**/api')
  • await page.wait('response')
  • await browser.waitForResponse('**/api')
  • await page.waitForResponse('**/api')
    28 How do you skip a test in Playwright?
  • test.ignore('test name', async ({ page }) => { /* code */ })
  • test.skip('test name', async ({ page }) => { /* code */ })
  • test.omit('test name', async ({ page }) => { /* code */ })
  • test.disable('test name', async ({ page }) => { /* code */ })
  • test.skip('test name', async ({ page }) => { /* code */ })
    29 How do you retry a failing test in Playwright?
  • test.retry(2)
  • page.retry(2)
  • browser.retry(2)
  • Use retries: 2 in the test config
  • Use retries: 2 in the test config
    30 How do you stop capturing a trace in Playwright?
  • await page.tracing.stop({ path: 'trace.zip' })
  • await page.stopTrace('trace.zip')
  • await browser.tracing.stop('trace.zip')
  • await page.traceEnd('trace.zip')
  • await page.tracing.stop({ path: 'trace.zip' })
    31 How do you disable JavaScript in Playwright?
  • await browser.disableJS()
  • await page.disableJavaScript()
  • await page.setJavaScriptEnabled(false)
  • await context.setJavaScriptEnabled(false)
  • await page.setJavaScriptEnabled(false)
    32 How do you set a geolocation in Playwright?
  • await page.setGeolocation({ latitude: 59.95, longitude: 30.33 })
  • await context.setGeolocation({ latitude: 59.95, longitude: 30.33 })
  • await browser.setGeolocation({ latitude: 59.95, longitude: 30.33 })
  • await playwright.setGeolocation({ latitude: 59.95, longitude: 30.33 })
  • await context.setGeolocation({ latitude: 59.95, longitude: 30.33 })
    33 How do you run tests in parallel in Playwright?
  • test.parallel()
  • test.concurrent()
  • page.parallelTests()
  • browser.runParallel()
  • test.parallel()
    34 How do you assert that an element has a specific attribute in Playwright?
  • await page.assertAttribute('selector','attr','value')
  • await page.checkAttribute('selector','attr','value')
  • await expect(page.locator('selector')).attributeEquals('attr','value')
  • await expect(page.locator('selector')).toHaveAttribute('attr','value')
  • await expect(page.locator('selector')).toHaveAttribute('attr','value')
    35 How do you check if an element is disabled in Playwright?
  • const isDisabled = await page.disabled('selector')
  • const isDisabled = await page.isDisabled('selector')
  • const isDisabled = await page.hasDisabled('selector')
  • const isDisabled = await page.verifyDisabled('selector')
  • const isDisabled = await page.isDisabled('selector')