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
• 10,950 points
336 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,520 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 22, 2019 by Abha
• 27,930 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 30 in Selenium by Sri
• 2,970 points
18,307 views
0 votes
1 answer
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,520 points
3,769 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

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

answered Aug 31 in Selenium by Sri
• 2,970 points
4,749 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,890 points
2,729 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 2 in Selenium by Sri
• 2,970 points
3,093 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 1 in Selenium by Sri
• 2,970 points
1,227 views
0 votes
1 answer