Created
July 6, 2013 09:46
-
-
Save arex1337/5939414 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 System; | |
using System.Drawing.Imaging; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using OpenQA.Selenium; | |
namespace SomeNamespace | |
{ | |
[TestClass] | |
public class BaseTest | |
{ | |
public ScreenShotRemoteWebDriver Driver { get; set; } | |
public TestContext TestContext { get; set; } | |
[TestInitialize] | |
public void BaseTestInitialize() | |
{ | |
this.Driver = DriverFactory.GetDriver(); | |
} | |
[TestCleanup] | |
public void BaseTestCleanup() | |
{ | |
if (this.TestContext.CurrentTestOutcome == UnitTestOutcome.Failed) | |
{ | |
var filename = System.IO.Path.GetTempPath() + DateTime.Now.ToString("yy-MM-dd-HH-mm-ss-FFF") + "-" + this.GetType().Name +"-" + this.TestContext.TestName + ".jpg"; | |
((ITakesScreenshot)this.Driver).GetScreenshot().SaveAsFile(filename, ImageFormat.Jpeg); | |
this.TestContext.AddResultFile(filename); | |
} | |
this.Driver.Quit(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment