- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 take partial screenshot with Selenium WebDriver in python?
We can take a partial screenshot with Selenium webdriver. To capture the screenshot of a particular element we have to first identify the element with the help of the locators like id, name, classname and so on.
Then we have to apply the screenshot method on that webelement and pass the image name with extension as an argument to the method. A new file containing the screenshot of that webelement gets created in the project folder.
Let us obtain the screenshot of the logo of the webpage.
from selenium import webdriver driver = webdriver.Chrome (executable_path="C:\chromedriver.exe") driver.maximize_window() driver.get("https://www.tutorialspoint.com/index.htm") # identify element to capture the screenshot l=driver.find_element_by_xpath("//img[@title='Tutorialspoint']") # capture the screenshot with screenshot method l.screenshot("logo.png")
A new file name logo.png containing a screenshot of the element gets created in the project folder.
- How to take partial screenshot (frame) with Selenium WebDriver?
- How to take screenshot with Selenium WebDriver?
- Take screenshot of full page with Selenium Python with chromedriver.
- How install Selenium Webdriver with Python?
- Take screenshot of the options in dropdown in selenium c#.
- How to get the complete screenshot of a page in Selenium with python?
- Best way to take screenshot of a web page into Selenium?
- How to take screenshot in Android Programatically?
- Screenshot of a particular element with Python Selenium in Linux
- How to get selected option using Selenium WebDriver with Python?
- How to programmatically take a screenshot in android?
- How to capture the screenshot of a specific element rather than entire page using Selenium Webdriver?
- How to take a screenshot of the window using Python?(Tkinter)
- How to send cookies with selenium webdriver?