Created
March 6, 2014 11:09
-
-
Save FriendlyTester/9387475 to your computer and use it in GitHub Desktop.
IWebDriver Screenshot Extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using OpenQA.Selenium; | |
using OpenQA.Selenium.Support.UI; | |
using System; | |
using System.Drawing.Imaging; | |
namespace Richard.WebDriverExtensions | |
{ | |
public static class WebDriverExtensions | |
{ | |
/// <summary> | |
/// Take a screenshot of the current page | |
/// </summary> | |
/// <param name="driver"></param> | |
/// <param name="FileLocationName">Full directory plus the file name and format, e.g C:\Temp\Image.jpeg</param> | |
/// <param name="imageFormat">System image format, I tend to stick to jpeg</param> | |
public static void TakeScreenshot(this IWebDriver driver, string FileLocationName, ImageFormat imageFormat) | |
{ | |
((ITakesScreenshot)driver).GetScreenshot().SaveAsFile(FileLocationName, imageFormat); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment