- 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
Screenshot of a particular element with Python Selenium in Linux
We can capture a screenshot of a particular element with Selenium webdriver in Python. To achieve this task, first we have to identify the element which we want to identify with the help of any locators like id, xpath, css, name, class name, tagname, link text or partial link text.
After the element has been identified, we can capture its screenshot with the help of the screenshot method. We have to pass the file name where the screenshot shall be stored (along with extension) as a parameter to this method
Let us capture the screenshot of the highlighted text below −
from selenium import webdriver #set chromodriver.exe path driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") driver.implicitly_wait(0.5) #launch URL driver.get("https://www.tutorialspoint.com/index.htm") #identify element m = driver.find_element_by_tag_name("h4") #capture screenshot and save it in .png extension m.screenshot("screenshot_text.png") #browser quit driver.quit()
- How to capture a screenshot of a particular element in Selenium 4.0?
- 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 screenshot of a particular section of the page like the logo of a website in Selenium with python?
- How to get the complete screenshot of a page in Selenium with python?
- How to take partial screenshot with Selenium WebDriver in python?
- How to take screenshot with Selenium WebDriver?
- Shutter the ultimate linux screenshot program
- How to take partial screenshot (frame) with Selenium WebDriver?
- How to capture the screenshot of a specific element rather than entire page using Selenium Webdriver?
- How to get the values of a particular row in a table in Selenium with python?
- Best way to take screenshot of a web page into Selenium?
- Take screenshot of the options in dropdown in selenium c#.
- Checking if element exists with Python Selenium.
- How to check a particular checkbox from a set of checkboxes in a page in Selenium with python?