O'Reilly logo

Learning Selenium Testing Tools with Python by Unmesh Gundecha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Capturing screenshots of failures

Capturing screenshots during the test run comes very handy when you want to communicate failures to the developers. It also helps in debugging tests or creating evidence of the test run. Selenium WebDriver comes with built-in methods to capture screenshots during the test run. The WebDriver class provides the following methods to capture and save a screenshot:

Method

Description

Argument

Example

Save_screenshot(filename)

This method gets the screenshot of the current window and saves the image to the specified file.

filename: This is the path/name of the file to which the screenshot will be saved

Driver.save_screenshot("homepage.png")

get_screenshot_as_base64()

This method gets the screenshot of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required