Taking Screenshot using Selenium WebDriver

0 votes
While taking the screenshot using Selenium Webdriver on windows browser and using python programming language, the screenshot is saved directly to the path of the program, is there a way to save the .png file to a specific directory, if yes then kindly tell me the solution?
Jul 12, 2018 in Selenium by 93.lynn
• 1,600 points
1,465 views

1 answer to this question.

0 votes

Using driver.save_screenshot('/path/to/file') we will be able to do it as shown below:

import selenium.webdriver as webdriver
import contextlib

@contextlib.contextmanager
def quitting(thing):
    yield thing
    thing.quit()

with quitting(webdriver.Firefox()) as driver:
    driver.implicitly_wait(10)
    driver.get('http://www.google.com')
    driver.save_screenshot('/tmp/google.png')
---------------

answered Jul 12, 2018 by Meci Matt
• 9,460 points

Related Questions In Selenium

0 votes
1 answer

Screenshot using Selenium WebDriver

Below code will help you using JAVA: WebDriver ...READ MORE

answered Apr 9, 2018 in Selenium by nsv999
• 5,500 points
818 views
0 votes
1 answer

How to capture screenshot of a webpage using Selenium Webdriver?

Hi Bindiya, you can use TakesScreenshot interface to capture the ...READ MORE

answered Jul 8, 2019 in Selenium by Abha
• 28,140 points
1,696 views
0 votes
1 answer

How can I capture full webpage screenshot using Selenium Webdriver?

Hey Harbhajan, you can use Ashot() to ...READ MORE

answered Jul 29, 2019 in Selenium by Anvi
• 14,150 points
4,681 views
0 votes
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,762 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,184 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,257 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,895 views
0 votes
1 answer

How to take screenshot of a frame using Selenium WebDriver?

you can use the below code: import java.awt.image.BufferedImage; import ...READ MORE

answered Jun 20, 2018 in Selenium by Meci Matt
• 9,460 points
3,501 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP