- 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
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.
- Take screenshot of the options in dropdown in selenium c#.
- How to take screenshot in Android Programatically?
- How install Selenium Webdriver with Python?
- Best way to take screenshot of a web page into Selenium?
- How to programmatically take a screenshot in android?
- How to programmatically take a screenshot on iOS?
- How to take a screenshot of the window using Python?(Tkinter)
- How to take a screenshot programmatically in iPhone/iOS?
- How to get the complete screenshot of a page in Selenium with python?
- Screenshot of a particular element with Python Selenium in Linux
- How to take a screenshot programmatically in Android using Kotlin?