How to take screenshot with Selenium Web driver using C#
Selenium web driver provides “Screenshot” class to take the
screenshots. Screenshots are really helpful to trace the error after execution
of selenium script. It can be saved at the specified location.
Please find below code snippet for it.
using
OpenQA.Selenium.Firefox;
using OpenQA.Selenium;
using System.Drawing;
using
System.Drawing.Imaging;
Public void Takescreenshot(IWebdriver _driver)
{
Screenshot
ss;
ss=((ITakesScreenshot)_driver).GetScreenshot();
ss.SaveAsFile("Filename.png",ImageFormat.Png);
}
What is type Screenshot? Also, it's GetScreenshotAs(OutputType.XXXX)
ReplyDeleteExample:
WebDriver augmentedDriver = new Augmenter().augment(getDriver());
File screenshot = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);
try {
FileUtils.copyFile(screenshot, new
File(SCREENSHOT_PATH + "/screenshot.png"));
} catch (IOException e) {
e.printStackTrace();
}
WOW just what I was searching for. Came here by searching
ReplyDeletefor windows
Here is my web-site ... google themes
My site: google chrome themes
Good day! I know this is kinda off topic however , I'd figured I'd ask.
ReplyDeleteWould you be interested in trading links
or maybe guest authoring a blog post or vice-versa? My blog covers a lot of the
same subjects as yours and I believe we could greatly benefit from each other.
If you are interested feel free to send me an email.
I look forward to hearing from you! Terrific blog by
the way!
Stop by my web blog ... advice