Take Screenshot - naveens33/selenium_python GitHub Wiki

Why Screenshot is necessary

Screenshots mainly helps in defect analysis and helps you to understand the what happened in particular moments of failure of the script.

Take Screenshot using the Selenium Webdriver method

Below method is used to take the screenshot of your web page

driver.save_screenshot('screenshot1.png')

Take Screenshot PIL.ImageGrab

With the Selenium Webdriver screenshot method. You can take a screenshot of the alert boxes. In order to achieve that you can use PIL.ImageGrab.

    import PIL.ImageGrab
    im = PIL.ImageGrab.grab()
    im.save("screenshot.png", "PNG")