- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Take screenshot of full page with Selenium Python with chromedriver.
We can take a screenshot of a full page with Selenium webdriver in Python with chromedriver. First of all, we shall obtain the original window size with the get_window_size method.
Next, capture the screenshot of the entire content within the body tag in the html with the screenshot method. This method accepts the path of the screenshot that will be captured as a parameter.
from selenium import webdriver #set chromodriver.exe path driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") driver.maximize_window() #launch URL driver.get("https://www.tutorialspoint.com/index.htm") #get window size s = driver.get_window_size() #obtain browser height and width w = driver.execute_script('return document.body.parentNode.scrollWidth') h = driver.execute_script('return document.body.parentNode.scrollHeight') #set to new window size driver.set_window_size(w, h) #obtain screenshot of page within body tag driver.find_element_by_tag_name('body').screenshot("tutorialspoint.png") driver.set_window_size(s['width'], s['height']) driver.quit()
A new file called tutorialspoint.png gets created in the project folder.
Right−click on it and then select Properties. The Properties for pop−up comes up. Copy the location field.
Open it in a browser.
- How to take screenshot with Selenium WebDriver?
- How to take partial screenshot with Selenium WebDriver in python?
- Best way to take screenshot of a web page into Selenium?
- How to take partial screenshot (frame) with Selenium WebDriver?
- How to get the complete screenshot of a page in Selenium with python?
- How to get the screenshot of a particular element in the page in Selenium with python?
- Screenshot of a particular element with Python Selenium in Linux
- Can you take a screenshot of the page using HTML5 Canvas?
- Take screenshot of the options in dropdown in selenium c#.
- How to get screenshot of full webpage using Selenium and Java?
- Save a Web Page with Python Selenium
- How to get the screenshot of a particular section of the page like the logo of a website in Selenium with python?
- Full page drag and drop files website with HTML
- How to take a screenshot of the window using Python?(Tkinter)