Skip to content

Commit

Permalink
Merge pull request #44 from aquality-automation/Feature/update-target…
Browse files Browse the repository at this point in the history
…-framework

Update target framework to .NET Core 3.1 (tests) [+semver: minor]
  • Loading branch information
paveliam authored Apr 21, 2020
2 parents a2b8ec6 + e805ed3 commit facd820
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using OpenQA.Selenium;

namespace Aquality.WinAppDriver.Actions
namespace Aquality.WinAppDriver.Actions
{
/// <summary>
/// Represents action keys which could be used in <see cref="IKeyboardActions"/>.
/// Used to enhance logging of SendKeys actions
/// Directly related to <see cref="Keys"/>
/// Directly related to <see cref="OpenQA.Selenium.Keys"/>
/// </summary>
public enum ActionKey
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public abstract class ApplicationActions
private readonly ILocalizedLogger localizedLogger;
private readonly Func<WindowsDriver<WindowsElement>> windowsDriverSupplier;


/// <summary>
/// Instantiates Application actions.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using OpenQA.Selenium;

namespace Aquality.WinAppDriver.Actions
namespace Aquality.WinAppDriver.Actions
{
/// <summary>
/// Represents modifier keys which could be used in <see cref="IKeyboardActions"/>.
/// Directly related to <see cref="Keys"/>
/// Directly related to <see cref="OpenQA.Selenium.Keys"/>
/// </summary>
public enum ModifierKey
{
Expand Down Expand Up @@ -33,10 +31,6 @@ public enum ModifierKey
/// </summary>
LeftShift,
/// <summary>
/// Represents the function key META.
/// </summary>
Meta,
/// <summary>
/// Represents the Shift key.
/// </summary>
Shift
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using OpenQA.Selenium.Appium.Service;

namespace Aquality.WinAppDriver.Configurations
{
Expand All @@ -9,7 +8,8 @@ namespace Aquality.WinAppDriver.Configurations
public interface IApplicationProfile
{
/// <summary>
/// Is remote WinAppDriver service or not: true to use <see cref="RemoteConnectionUrl"/> and false to create default <see cref="AppiumLocalService"/>.
/// Is remote WinAppDriver service or not: true to use <see cref="RemoteConnectionUrl"/>
/// and false to create default <see cref="OpenQA.Selenium.Appium.Service.AppiumLocalService"/>.
/// </summary>
bool IsRemote { get; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand All @@ -12,7 +12,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Aquality.WinAppDriver.Applications;
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;

namespace Aquality.WinAppDriver.Tests
{
internal class ScreenshotProvider
{
private readonly IWindowsApplication application;

internal ScreenshotProvider(IWindowsApplication application)
{
this.application = application;
}

internal string TakeScreenshot()
{
var image = GetImage();
var directory = Path.Combine(Environment.CurrentDirectory, "screenshots");
EnsureDirectoryExists(directory);
var screenshotName = $"{GetType().Name}_{DateTime.Now:yyyyMMdd_HHmmss}_{Guid.NewGuid().ToString("n").Substring(0, 5)}.png";
var path = Path.Combine(directory, screenshotName);
image.Save(path, ImageFormat.Png);
return path;
}

private Image GetImage()
{
using (var stream = new MemoryStream(application.RootSession.GetScreenshot().AsByteArray))
{
return Image.FromStream(stream);
}
}

private static void EnsureDirectoryExists(string directory)
{
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Aquality.WinAppDriver.Applications;
using NUnit.Framework;
using NUnit.Framework.Interfaces;

namespace Aquality.WinAppDriver.Tests
{
Expand All @@ -11,6 +12,11 @@ public virtual void CleanUp()
{
if (AqualityServices.IsApplicationStarted)
{
if (TestContext.CurrentContext.Result.Outcome.Status != TestStatus.Passed)
{
TestContext.AddTestAttachment(new ScreenshotProvider(AqualityServices.Application).TakeScreenshot());
}

AqualityServices.Application.Quit();
}
AqualityServices.TryToStopAppiumLocalService();
Expand Down
34 changes: 21 additions & 13 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ steps:
extraProperties: |
sonar.coverage.exclusions=**/**
- script: dotnet build Aquality.WinAppDriver/Aquality.WinAppDriver.sln -c $(buildConfiguration)
displayName: 'Build solution - $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'Build solution'
inputs:
command: 'build'
projects: Aquality.WinAppDriver/Aquality.WinAppDriver.sln
arguments: -c $(buildConfiguration)

- task: SonarCloudAnalyze@1
displayName: 'Run SonarCloud code analysis'
Expand All @@ -36,6 +40,13 @@ steps:
displayName: 'Publish SonarCloud quality gate results'
continueOnError: true

- task: ScreenResolutionUtility@1
displayName: 'Set up screen resolution 1920x1080'
inputs:
displaySettings: 'specific'
width: '1920'
height: '1080'

- task: Windows Application Driver@0
displayName: 'Start WinAppDriver'
inputs:
Expand All @@ -50,21 +61,12 @@ steps:
publishTestResults: true

- task: Windows Application Driver@0
displayName: stop WinAppDriver
displayName: Stop WinAppDriver
inputs:
OperationType: 'Stop'

- script: dotnet pack Aquality.WinAppDriver\src\Aquality.WinAppDriver\Aquality.WinAppDriver.csproj -c $(buildConfiguration) --no-build -p:Version=$(GitVersion.NuGetVersion) -o $(Build.ArtifactStagingDirectory)
displayName: 'Create NuGet package'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))

- task: NuGetCommand@2
displayName: 'Push NuGet package'
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/Aquality.WinAppDriver*.nupkg;!$(Build.ArtifactStagingDirectory)/**/Aquality.WinAppDriver*.symbols.nupkg'
nuGetFeedType: 'external'
publishFeedCredentials: 'NuGet'
displayName: 'Pack to NuGet package'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))

- task: GitHubRelease@0
Expand All @@ -76,4 +78,10 @@ steps:
tag: 'v$(GitVersion.NuGetVersion)'
tagSource: 'manual'
isPreRelease: contains(variables['GitVersion.NuGetVersion'], '-')
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))

- task: PublishBuildArtifacts@1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactName: '_aquality-automation.aquality-winappdriver-dotnet'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))

0 comments on commit facd820

Please sign in to comment.