- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the complete screenshot of a page in Selenium with python?
We can get the complete screenshot of a page in Selenium. While executing any test cases, we might encounter failures. To keep track of the failures we capture a screenshot of the web page where the error exists.
In a test case, there may be failure for reasons listed below −
- If the assertion does not pass.
- If there are sync issues between our application and Selenium.
- If there are timeout issues.
- If an alert appears in between.
- If the element cannot be identified with the locators.
- If the actual and final results are not matching.
For capturing the screenshot, save_screenshot() method is available. This method takes the full page screenshot.
Syntax
driver.save_screenshot("screenshot_t.png")
In the arguments, we have to provide the screenshot file name along with the extension of .png. If anything else is used as extension, a warning message will be thrown and the image cannot be viewed.
The screenshot gets saved in the same path of the program.
Example
Code Implementation for full page screenshot.
from selenium import webdriver #browser exposes an executable file #Through Selenium test we will invoke the executable file which will then #invoke actual browser driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") # to maximize the browser window driver.maximize_window() #get method to launch the URL driver.get("https://www.tutorialspoint.com/index.htm") #to refresh the browser driver.refresh() #to get the screenshot of complete page driver.save_screenshot("screenshot_tutorialspoint.png") #to close the browser driver.close()
- Related Articles
- How to get the screenshot of a particular element in the page in Selenium with python?
- Take screenshot of full page with Selenium Python with chromedriver.
- How to get the title and URL of the page in Selenium with python?
- Best way to take screenshot of a web page into Selenium?
- How to take partial screenshot with Selenium WebDriver in python?
- Screenshot of a particular element with Python Selenium in Linux
- How to capture the screenshot of a specific element rather than entire page using Selenium Webdriver?
- How to take screenshot with Selenium WebDriver?
- How to get screenshot of full webpage using Selenium and Java?
- How to get all the values including the headers inside a table in a page in Selenium with python?
- How to count the number of checkboxes in a page in Selenium with python?
- How to check a checkbox in a page in Selenium with python?
- How to find the status of an element in a page in Selenium with python?
- How to count the total number of tables in a page in Selenium with python?
- How to get the total number of checkboxes in a page using Selenium?

Advertisements