Skip to content
Related Articles

Related Articles

Improve Article

How to take screenshot using Selenium in Python ?

  • Last Updated : 30 Jun, 2021

Selenium offers a lot of features and one of the important and useful feature is of taking a screenshot. In order to take a screenshot of webpage save_screenshot() method is used. save_screenshot method allows user to save the webpage as a png file.

Syntax : 


Argument : 
filename or the full path you wish to save your screenshot to.

Action performed : 
The screenshot will be saved in the same directory as the program, if path is provided screenshot will be saved at that location only.

Code :  


# importing webdriver from selenium
from selenium import webdriver
from PIL import Image
# Here Chrome  will be used
driver = webdriver.Chrome()
# URL of website
# Opening the website
# Loading the image
image ="image.png")
# Showing the image

Output : 


 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :