wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Playwright Quiz 1

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

What is one key benefit of automation testing compared to manual testing?

a)

Lower initial setup cost

b)

Faster execution of tests

c)

More frequent human errors

d)

Greater flexibility in test cases

2.

Which of the following is a typical advantage of automation testing?

a)

Increased time to run each test

b)

Reduced test coverage

c)

Reusability of test scripts

d)

Limited scalability

3.

Question 3: Which language does Playwright support for writing tests?

a)

A. Java

b)

B. Python

c)

C. JavaScript/TypeScript

d)

D. Ruby

4.

Question 4: What does the page.goto() function do in Playwright?

a)

A. Navigates to a specific URL

b)

B. Clicks on a button

c)

C. Takes a screenshot

d)

D. Waits for a network request

5.

Question 5: In Playwright, which function is used to fill input fields?

a)

A. page.type()

b)

B. page.fill()

c)

C. page.click()

d)

D. page.select()

6.

Question 5: Which of the following is NOT a feature of Playwright?

a)

A. Multi-browser support

b)

B. Mobile device emulation

c)

C. Code coverage

d)

D. Direct database testing

7.

Question 7: How do you wait for an element to become visible in Playwright?

a)

A. page.waitForSelector()

b)

B. page.waitForElement()

c)

C. page.waitForVisible()

d)

D. page.waitFor()

8.

Question 8: Which Playwright function allows you to take a screenshot?

a)

A. page.screenshot()

b)

B. page.capture()

c)

C. page.image()

d)

D. page.snap()

9.

Question 9: In Playwright, how do you select an element by its text content?

a)

A. page.selectByText()

b)

B. page.getByText()

c)

C. page.findByText()

d)

D. page.querySelectorByText()

10.

Question 10: What is the Playwright function to simulate a click on an element?

a)

A. page.tap()

b)

B. page.touch()

c)

C. page.click()

d)

D. page.press()

11.

Question 11: How does automation testing improve efficiency compared to manual testing?

a)

A. By requiring more manual intervention

b)

B. By automating repetitive tasks

c)

C. By reducing the number of test cases

d)

D. By slowing down the testing process

12.

Question 12: What is a key feature of Playwright that differentiates it from other testing tools?

a)

A. Support for only one browser

b)

B. Built-in support for API testing

c)

C. Ability to handle multiple browser contexts

d)

D. Lack of mobile emulation

13.

Question 13: How do you configure Playwright to run tests on different browsers?

a)

A. By setting browser options in playwright.config.js

b)

B. By modifying the test script

c)

C. By changing environment variables

d)

D. By using different testing libraries

14.

Question 14: In Playwright, what is the purpose of the context object?

a)

A. To handle user authentication

b)

B. To manage multiple browser tabs or pages

c)

C. To set global variables

d)

D. To configure test reporting

15.

Question 15: How can you run Playwright tests in parallel?

a)

A. By using test.parallel()

b)

B. By configuring parallelism in the test runner

c)

C. By manually starting multiple instances

d)

D. By using different test files

16.

Question 16: Which method is used to interact with a page element’s state in Playwright?

a)

A. element.getState()

b)

B. element.setValue()

c)

C. element.getAttribute()

d)

D. element.evaluate()

17.

Question 17: What is the advantage of using Playwright’s page.evaluate() method?

a)

A. It allows interaction with elements only

b)

B. It enables JavaScript execution within the page context

c)

C. It provides automatic error reporting

d)

D. It manages browser cookies

18.

Question 18: How do you capture network requests in Playwright?

a)

A. By using page.monitor()

b)

B. By setting up request listeners

c)

C. By enabling network logging

d)

D. By using browser developer tools

19.

Question 19: How do you test multiple user scenarios in a single Playwright test?

a)

A. By using different test files

b)

B. By running tests sequentially

c)

C. By creating multiple browser contexts

d)

D. By modifying the test script dynamically

20.

Question 20: Which Playwright function is used to emulate mobile devices?

a)

A. page.emulate()

b)

B. context.setViewport()

c)

C. browser.newContext({ ... })

d)

D. page.setDevice()

21.

Question 21: What does the toHaveScreenshot assertion in Playwright test?

a)

A. It checks if a page has loaded successfully

b)

B. It verifies if an element is visible on the page

c)

C. It validates the page's performance metrics

d)

D. It compares the current screenshot with a reference screenshot

22.

Question 22: In the following Playwright test, what does the toHaveScreenshot assertion do?

test('screenshot test', async ({ page }) => { await page.goto('https://playwright.dev'); await expect(page).toHaveScreenshot({ maxDiffPixels: 100 }); });

a)

A. It takes a screenshot of the page and saves it to a file

b)

B. It verifies that the current screenshot matches a baseline screenshot within a pixel difference limit

c)

C. It checks if the page has loaded completely

d)

D. It captures a screenshot of a specific element on the page

23.

Question 23: Which Playwright method returns the first element in a set of elements that match a search condition?

a)

A. page.getByText()

b)

B. page.last()

c)

C. page.first()

d)

D. page.nth()

24.

Question 24: When is it most appropriate to use getByText() instead of CSS selectors in Playwright?

a)

A. When you need to locate an element based on its text content.

b)

B. When selecting elements by their ID

c)

C. When selecting elements by class name

d)

D. When selecting elements based on their hierarchical position

25.

Question 25: Which Playwright method would you use to select the last element in a set of elements that match a search condition?

a)

A. page.first()

b)

B. page.last()

c)

C. page.nth()

d)

D. page.getByText()