Skip to content

Commit

Permalink
- #783 Use Selenium.WebDriver package v4.14.0
Browse files Browse the repository at this point in the history
- #784 Deprecate `ScreenshotImageFormat` configuration for screenshots
  • Loading branch information
YevgeniyShunevych committed Oct 16, 2023
1 parent 75b5e4e commit 21028f2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Atata/Atata.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Features:
<ItemGroup>
<PackageReference Include="Atata.WebDriverExtras" Version="2.3.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.13.1" />
<PackageReference Include="Selenium.WebDriver" Version="4.14.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public static class ScreenshotConsumerAtataContextBuilderExtensions
/// <param name="builder">The builder.</param>
/// <param name="imageFormat">The image format.</param>
/// <returns>The same builder instance.</returns>
[Obsolete("Don't use this method as it will be removed. Atata will only support the PNG format, as will Selenium.WebDriver.")] // Obsolete since v2.11.0.
public static ScreenshotConsumerAtataContextBuilder<TConsumer> With<TConsumer>(
this ScreenshotConsumerAtataContextBuilder<TConsumer> builder,
ScreenshotImageFormat imageFormat)
Expand Down
2 changes: 2 additions & 0 deletions src/Atata/Extensions/ScreenshotImageFormatExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
namespace Atata;

// TODO: Atata v3. Remove class.
public static class ScreenshotImageFormatExtensions
{
[Obsolete("Don't use this method as it will be removed.")] // Obsolete since v2.11.0.
public static string GetExtension(this ScreenshotImageFormat format) =>
format == ScreenshotImageFormat.Jpeg
? ".jpg"
Expand Down
5 changes: 5 additions & 0 deletions src/Atata/Logging/FileScreenshotConsumerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public abstract class FileScreenshotConsumerBase : IScreenshotConsumer
/// Gets or sets the image format.
/// The default format is <see cref="OpenQA.Selenium.ScreenshotImageFormat.Png"/>.
/// </summary>
[Obsolete("Don't use this property as it will be removed. Atata will only support the PNG format, as will Selenium.WebDriver.")] // Obsolete since v2.11.0.
public ScreenshotImageFormat ImageFormat { get; set; } = ScreenshotImageFormat.Png;

/// <summary>
Expand All @@ -16,7 +17,9 @@ public void Take(ScreenshotInfo screenshotInfo)
{
string filePath = BuildFilePath(screenshotInfo);
filePath = filePath.SanitizeForPath();
#pragma warning disable CS0618 // Type or member is obsolete
filePath += ImageFormat.GetExtension();
#pragma warning restore CS0618 // Type or member is obsolete

if (!Path.IsPathRooted(filePath))
filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filePath);
Expand Down Expand Up @@ -51,9 +54,11 @@ public void Take(ScreenshotInfo screenshotInfo)

private void SaveImage(ScreenshotInfo screenshotInfo, string filePath)
{
#pragma warning disable CS0618 // Type or member is obsolete
if (ImageFormat == ScreenshotImageFormat.Png)
screenshotInfo.ScreenshotContent.Save(filePath);
else
screenshotInfo.Screenshot.SaveAsFile(filePath, ImageFormat);
#pragma warning restore CS0618 // Type or member is obsolete
}
}

0 comments on commit 21028f2

Please sign in to comment.