Recall & Review
beginner
What is the purpose of taking a screenshot on test failure in Selenium?
Taking a screenshot on test failure helps to capture the exact state of the web page when the test failed. This makes it easier to understand what went wrong and debug the issue.
Click to reveal answer
beginner
Which Selenium WebDriver method is used to capture a screenshot in Python?
The method
driver.save_screenshot('filename.png') is used to capture and save a screenshot of the current browser window.Click to reveal answer
intermediate
How can you automatically take a screenshot only when a test fails in Python unittest?
You can override the
tearDown method to check if the test failed, and if so, call driver.save_screenshot() to save the screenshot.Click to reveal answer
beginner
Why is it important to name screenshot files with timestamps or test names?
Naming screenshots with timestamps or test names prevents overwriting files and helps quickly identify which test and time the screenshot belongs to.
Click to reveal answer
intermediate
What is a simple way to integrate screenshot capture on failure in pytest?
In pytest, you can use the
request.node.rep_call.failed hook in a fixture to detect failure and then call driver.save_screenshot() to save the screenshot.Click to reveal answer
Which Selenium WebDriver method saves a screenshot in Python?
✗ Incorrect
The correct method is
save_screenshot() which saves the current browser window as an image file.When should you take a screenshot during automated testing?
✗ Incorrect
Taking screenshots on failure helps capture the error state for debugging.
In unittest, which method is best to override to add screenshot capture on failure?
✗ Incorrect
The
tearDown() method runs after each test and is ideal to check for failure and capture screenshots.Why add timestamps to screenshot filenames?
✗ Incorrect
Timestamps help avoid overwriting files and make it easier to track when the screenshot was taken.
Which Python testing framework allows using fixtures to capture screenshots on failure?
✗ Incorrect
pytest supports fixtures that can detect test failure and capture screenshots automatically.
Explain how to implement automatic screenshot capture on test failure using Selenium with Python unittest.
Think about what happens after each test and how to detect failure.
You got /4 concepts.
Describe best practices for naming and storing screenshots taken on test failure.
Consider how to keep screenshots easy to find and identify.
You got /4 concepts.