WorksheetsPlaywright Quiz 1
Total questions: 25
Worksheet time: 13mins
What is one key benefit of automation testing compared to manual testing?
Lower initial setup cost
Faster execution of tests
More frequent human errors
Greater flexibility in test cases
Which of the following is a typical advantage of automation testing?
Increased time to run each test
Reduced test coverage
Reusability of test scripts
Limited scalability
Question 3: Which language does Playwright support for writing tests?
A. Java
B. Python
C. JavaScript/TypeScript
D. Ruby
Question 4: What does the page.goto() function do in Playwright?
A. Navigates to a specific URL
B. Clicks on a button
C. Takes a screenshot
D. Waits for a network request
Question 5: In Playwright, which function is used to fill input fields?
A. page.type()
B. page.fill()
C. page.click()
D. page.select()
Question 5: Which of the following is NOT a feature of Playwright?
A. Multi-browser support
B. Mobile device emulation
C. Code coverage
D. Direct database testing
Question 7: How do you wait for an element to become visible in Playwright?
A. page.waitForSelector()
B. page.waitForElement()
C. page.waitForVisible()
D. page.waitFor()
Question 8: Which Playwright function allows you to take a screenshot?
A. page.screenshot()
B. page.capture()
C. page.image()
D. page.snap()
Question 9: In Playwright, how do you select an element by its text content?
A. page.selectByText()
B. page.getByText()
C. page.findByText()
D. page.querySelectorByText()
Question 10: What is the Playwright function to simulate a click on an element?
A. page.tap()
B. page.touch()
C. page.click()
D. page.press()
Question 11: How does automation testing improve efficiency compared to manual testing?
A. By requiring more manual intervention
B. By automating repetitive tasks
C. By reducing the number of test cases
D. By slowing down the testing process
Question 12: What is a key feature of Playwright that differentiates it from other testing tools?
A. Support for only one browser
B. Built-in support for API testing
C. Ability to handle multiple browser contexts
D. Lack of mobile emulation
Question 13: How do you configure Playwright to run tests on different browsers?
A. By setting browser options in playwright.config.js
B. By modifying the test script
C. By changing environment variables
D. By using different testing libraries
Question 14: In Playwright, what is the purpose of the context object?
A. To handle user authentication
B. To manage multiple browser tabs or pages
C. To set global variables
D. To configure test reporting
Question 15: How can you run Playwright tests in parallel?
A. By using test.parallel()
B. By configuring parallelism in the test runner
C. By manually starting multiple instances
D. By using different test files
Question 16: Which method is used to interact with a page element’s state in Playwright?
A. element.getState()
B. element.setValue()
C. element.getAttribute()
D. element.evaluate()
Question 17: What is the advantage of using Playwright’s page.evaluate() method?
A. It allows interaction with elements only
B. It enables JavaScript execution within the page context
C. It provides automatic error reporting
D. It manages browser cookies
Question 18: How do you capture network requests in Playwright?
A. By using page.monitor()
B. By setting up request listeners
C. By enabling network logging
D. By using browser developer tools
Question 19: How do you test multiple user scenarios in a single Playwright test?
A. By using different test files
B. By running tests sequentially
C. By creating multiple browser contexts
D. By modifying the test script dynamically
Question 20: Which Playwright function is used to emulate mobile devices?
A. page.emulate()
B. context.setViewport()
C. browser.newContext({ ... })
D. page.setDevice()
Question 21: What does the toHaveScreenshot assertion in Playwright test?
A. It checks if a page has loaded successfully
B. It verifies if an element is visible on the page
C. It validates the page's performance metrics
D. It compares the current screenshot with a reference screenshot
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. It takes a screenshot of the page and saves it to a file
B. It verifies that the current screenshot matches a baseline screenshot within a pixel difference limit
C. It checks if the page has loaded completely
D. It captures a screenshot of a specific element on the page
Question 23: Which Playwright method returns the first element in a set of elements that match a search condition?
A. page.getByText()
B. page.last()
C. page.first()
D. page.nth()
Question 24: When is it most appropriate to use getByText() instead of CSS selectors in Playwright?
A. When you need to locate an element based on its text content.
B. When selecting elements by their ID
C. When selecting elements by class name
D. When selecting elements based on their hierarchical position
Question 25: Which Playwright method would you use to select the last element in a set of elements that match a search condition?
A. page.first()
B. page.last()
C. page.nth()
D. page.getByText()
