How can we take screenshots of tests in Selenium 2 using C

0 votes
I need to take screenshots of my functional tests. As of now I'm using Selenium 2 with C# bindings. I pretty much want to take a screenshot at the end of the test to make sure the desired page is displayed. Are there any external tools I can use with my C# code for taking a screenshot? I couldn't find any way to do in Selenium 2
Mar 23, 2018 in Selenium by nitinrawat895
• 11,380 points
973 views

2 answers to this question.

0 votes

We can take screenshots using below function calls: 

driver = new FireFoxDriver(); // Should work in other Browser Driver
driver.Navigate().GoToUrl("Your_URL"); 
Screenshot myscreen = ((ITakesScreenshot)webDriver).GetScreenshot(); 
myscreen.SaveAsFile("filename", ScreenshotImageFormat.Png); 

This should work...do let me know if it works.

answered Mar 23, 2018 by nsv999
• 5,500 points
0 votes

Hey, try using following code command to take screenshot in Selenium using C#:

((ITakesScreenshot)FirefoxInstance).GetScreenshot().SaveAsFile("File Location",System.Drawing.Imaging.ImageFormat.Jpeg);
answered Aug 23, 2019 by Abha
• 28,140 points

Related Questions In Selenium

+2 votes
3 answers

How can we handle authentication popup in Selenium WebDriver using Java

1) By passing user credentials in URL. String ...READ MORE

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

How can I perform multiple selection of options in a dropdown using Select class in Selenium?

Hey Priyansh, you can select multiple options ...READ MORE

answered Jul 8, 2019 in Selenium by Anvi
• 14,150 points
2,907 views
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
12,617 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
8,572 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
6,629 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,519 views
0 votes
3 answers

Can we run selenium tests (Firefox) on WebDriver without a GUI?

Hi ,  Yes, you can use headless browsers ...READ MORE

answered Sep 2, 2020 in Selenium by Sri
• 3,190 points
3,547 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