Skip to content

Commit

Permalink
Removing deprecated screenshot formats in .NET
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Aug 15, 2017
1 parent 3690155 commit e353672
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
14 changes: 1 addition & 13 deletions dotnet/src/webdriver/Screenshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,11 @@ public byte[] AsByteArray
/// <param name="format">A <see cref="ScreenshotImageFormat"/> value indicating the format
/// to save the image to.</param>
public void SaveAsFile(string fileName, ScreenshotImageFormat format)
{
this.SaveAsFile(fileName, ConvertScreenshotImageFormat(format));
}

/// <summary>
/// Saves the screenshot to a file, overwriting the file if it already exists.
/// </summary>
/// <param name="fileName">The full path and file name to save the screenshot to.</param>
/// <param name="format">A <see cref="System.Drawing.Imaging.ImageFormat"/> object indicating the format
/// to save the image to.</param>
[Obsolete("System.Drawing.Imaging.ImageFormat is not supported in .NET Core, and depending on it is being removed from WebDriver. Please convert to ScreenshotImageFormat.")]
public void SaveAsFile(string fileName, ImageFormat format)
{
using (MemoryStream imageStream = new MemoryStream(this.byteArray))
{
Image screenshotImage = Image.FromStream(imageStream);
screenshotImage.Save(fileName, format);
screenshotImage.Save(fileName, ConvertScreenshotImageFormat(format));
}
}

Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/common/TakesScreenshotTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void ShouldTakeScreenshotsOfThePage()

string filename = Path.Combine(Path.GetTempPath(), "snapshot" + new Random().Next().ToString() + ".png");
Screenshot screenImage = screenshotCapableDriver.GetScreenshot();
screenImage.SaveAsFile(filename, System.Drawing.Imaging.ImageFormat.Png);
screenImage.SaveAsFile(filename, ScreenshotImageFormat.Png);
Assert.IsTrue(File.Exists(filename));
Assert.IsTrue(new FileInfo(filename).Length > 0);
File.Delete(filename);
Expand Down

0 comments on commit e353672

Please sign in to comment.