From 2dbe58edd26b6a3ad928a75d3b423b029387cffe Mon Sep 17 00:00:00 2001 From: Pavel Anihimovsky Date: Fri, 17 Apr 2020 11:37:21 +0300 Subject: [PATCH 01/10] Update target framework to .NET Core 3.1 --- .../Aquality.WinAppDriver.Tests.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/Aquality.WinAppDriver.Tests.csproj b/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/Aquality.WinAppDriver.Tests.csproj index af6dcfa..269429c 100644 --- a/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/Aquality.WinAppDriver.Tests.csproj +++ b/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/Aquality.WinAppDriver.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + netcoreapp3.1 false @@ -12,7 +12,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + From 4c2170cce1ae5e0292aab5af5278b8453256aacb Mon Sep 17 00:00:00 2001 From: Pavel Anihimovsky Date: Fri, 17 Apr 2020 17:29:03 +0300 Subject: [PATCH 02/10] Update pipeline --- azure-pipelines.yml | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5662657..a0fff41 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -25,8 +25,14 @@ 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' + env: + MSBUILDSINGLELOADCONTEXT: 1 # https://github.com/SpecFlowOSS/SpecFlow/issues/1912 + inputs: + command: 'build' + projects: Aquality.WinAppDriver/Aquality.WinAppDriver.sln + arguments: -c $(buildConfiguration) - task: SonarCloudAnalyze@1 displayName: 'Run SonarCloud code analysis' @@ -50,21 +56,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 @@ -76,4 +73,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')) \ No newline at end of file From 0334b71bd02cd6ba086d6a2b5325b4aefe9866b5 Mon Sep 17 00:00:00 2001 From: Pavel Anihimovsky Date: Fri, 17 Apr 2020 17:35:11 +0300 Subject: [PATCH 03/10] Update pipeline --- azure-pipelines.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a0fff41..fddd5f5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -25,14 +25,17 @@ steps: extraProperties: | sonar.coverage.exclusions=**/** -- task: DotNetCoreCLI@2 - displayName: 'Build solution' - env: - MSBUILDSINGLELOADCONTEXT: 1 # https://github.com/SpecFlowOSS/SpecFlow/issues/1912 - inputs: - command: 'build' - projects: Aquality.WinAppDriver/Aquality.WinAppDriver.sln - arguments: -c $(buildConfiguration) +#- task: DotNetCoreCLI@2 +# displayName: 'Build solution' +# env: +# MSBUILDSINGLELOADCONTEXT: 1 # https://github.com/SpecFlowOSS/SpecFlow/issues/1912 +# inputs: +# command: 'build' +# projects: Aquality.WinAppDriver/Aquality.WinAppDriver.sln +# arguments: -c $(buildConfiguration) + +- script: dotnet build Aquality.WinAppDriver/Aquality.WinAppDriver.sln -c $(buildConfiguration) + displayName: 'Build solution - $(buildConfiguration)' - task: SonarCloudAnalyze@1 displayName: 'Run SonarCloud code analysis' From 142f373c9c86af059286077d66968839bd0c131c Mon Sep 17 00:00:00 2001 From: Pavel Anihimovsky Date: Mon, 20 Apr 2020 15:43:34 +0300 Subject: [PATCH 04/10] Try to fix failing tests --- .../Aquality.WinAppDriver.Tests/Actions/KeyboardActionsTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/Actions/KeyboardActionsTests.cs b/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/Actions/KeyboardActionsTests.cs index 81d17c6..64c0e34 100644 --- a/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/Actions/KeyboardActionsTests.cs +++ b/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/Actions/KeyboardActionsTests.cs @@ -93,6 +93,7 @@ public void Should_ReleaseKey_ViaKeyboardActions() [Test] public void Should_NotThrow_WhenHoldModifierKeys_ViaKeyboardActions([ValueSource(nameof(modifierKeys))] ModifierKey modifierKey) { + RightArgumentTextBox.State.WaitForClickable(); RightArgumentTextBox.Click(); Assert.DoesNotThrow(() => KeyboardActions.SendKeysWithKeyHold(ValueToSend, modifierKey)); } From cdcfe808400422da390771be2320151a1df2e09c Mon Sep 17 00:00:00 2001 From: Pavel Anihimovsky Date: Mon, 20 Apr 2020 15:51:47 +0300 Subject: [PATCH 05/10] Update pipeline --- azure-pipelines.yml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fddd5f5..a0fff41 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -25,17 +25,14 @@ steps: extraProperties: | sonar.coverage.exclusions=**/** -#- task: DotNetCoreCLI@2 -# displayName: 'Build solution' -# env: -# MSBUILDSINGLELOADCONTEXT: 1 # https://github.com/SpecFlowOSS/SpecFlow/issues/1912 -# inputs: -# command: 'build' -# projects: Aquality.WinAppDriver/Aquality.WinAppDriver.sln -# arguments: -c $(buildConfiguration) - -- script: dotnet build Aquality.WinAppDriver/Aquality.WinAppDriver.sln -c $(buildConfiguration) - displayName: 'Build solution - $(buildConfiguration)' +- task: DotNetCoreCLI@2 + displayName: 'Build solution' + env: + MSBUILDSINGLELOADCONTEXT: 1 # https://github.com/SpecFlowOSS/SpecFlow/issues/1912 + inputs: + command: 'build' + projects: Aquality.WinAppDriver/Aquality.WinAppDriver.sln + arguments: -c $(buildConfiguration) - task: SonarCloudAnalyze@1 displayName: 'Run SonarCloud code analysis' From f925690c078c229fe6377dc67a73fb832ce0cd10 Mon Sep 17 00:00:00 2001 From: Pavel Anihimovsky Date: Tue, 21 Apr 2020 13:01:29 +0300 Subject: [PATCH 06/10] Add ScreenResolutionUtility task to pipeline --- .../Aquality.WinAppDriver/Actions/ApplicationActions.cs | 1 - .../Actions/KeyboardActionsTests.cs | 1 - azure-pipelines.yml | 7 +++++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Actions/ApplicationActions.cs b/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Actions/ApplicationActions.cs index 99c17b0..1608609 100644 --- a/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Actions/ApplicationActions.cs +++ b/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Actions/ApplicationActions.cs @@ -14,7 +14,6 @@ public abstract class ApplicationActions private readonly ILocalizedLogger localizedLogger; private readonly Func> windowsDriverSupplier; - /// /// Instantiates Application actions. /// diff --git a/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/Actions/KeyboardActionsTests.cs b/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/Actions/KeyboardActionsTests.cs index 64c0e34..81d17c6 100644 --- a/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/Actions/KeyboardActionsTests.cs +++ b/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/Actions/KeyboardActionsTests.cs @@ -93,7 +93,6 @@ public void Should_ReleaseKey_ViaKeyboardActions() [Test] public void Should_NotThrow_WhenHoldModifierKeys_ViaKeyboardActions([ValueSource(nameof(modifierKeys))] ModifierKey modifierKey) { - RightArgumentTextBox.State.WaitForClickable(); RightArgumentTextBox.Click(); Assert.DoesNotThrow(() => KeyboardActions.SendKeysWithKeyHold(ValueToSend, modifierKey)); } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a0fff41..3462f69 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,8 +27,6 @@ steps: - task: DotNetCoreCLI@2 displayName: 'Build solution' - env: - MSBUILDSINGLELOADCONTEXT: 1 # https://github.com/SpecFlowOSS/SpecFlow/issues/1912 inputs: command: 'build' projects: Aquality.WinAppDriver/Aquality.WinAppDriver.sln @@ -42,6 +40,11 @@ steps: displayName: 'Publish SonarCloud quality gate results' continueOnError: true +- task: ScreenResolutionUtility@1 + displayName: 'Set up optimal screen resolution' + inputs: + displaySettings: 'optimal' + - task: Windows Application Driver@0 displayName: 'Start WinAppDriver' inputs: From 9708871985add2f129045d7b6445ca6579e24fa3 Mon Sep 17 00:00:00 2001 From: Pavel Anihimovsky Date: Tue, 21 Apr 2020 13:21:43 +0300 Subject: [PATCH 07/10] Add screenshots and fix warnings --- .../Actions/ActionKey.cs | 6 +-- .../Actions/ModifierKey.cs | 6 +-- .../Aquality.WinAppDriver.xml | 3 +- .../Configurations/IApplicationProfile.cs | 4 +- .../ScreenshotProvider.cs | 45 +++++++++++++++++++ .../TestWithApplication.cs | 6 +++ azure-pipelines.yml | 5 --- 7 files changed, 59 insertions(+), 16 deletions(-) create mode 100644 Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/ScreenshotProvider.cs diff --git a/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Actions/ActionKey.cs b/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Actions/ActionKey.cs index 41fd9ab..bc31b6d 100644 --- a/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Actions/ActionKey.cs +++ b/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Actions/ActionKey.cs @@ -1,11 +1,9 @@ -using OpenQA.Selenium; - -namespace Aquality.WinAppDriver.Actions +namespace Aquality.WinAppDriver.Actions { /// /// Represents action keys which could be used in . /// Used to enhance logging of SendKeys actions - /// Directly related to + /// Directly related to /// public enum ActionKey { diff --git a/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Actions/ModifierKey.cs b/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Actions/ModifierKey.cs index f87a8ca..3213e7a 100644 --- a/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Actions/ModifierKey.cs +++ b/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Actions/ModifierKey.cs @@ -1,10 +1,8 @@ -using OpenQA.Selenium; - -namespace Aquality.WinAppDriver.Actions +namespace Aquality.WinAppDriver.Actions { /// /// Represents modifier keys which could be used in . - /// Directly related to + /// Directly related to /// public enum ModifierKey { diff --git a/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Aquality.WinAppDriver.xml b/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Aquality.WinAppDriver.xml index 3c52247..c6e1ab9 100644 --- a/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Aquality.WinAppDriver.xml +++ b/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Aquality.WinAppDriver.xml @@ -685,7 +685,8 @@ - Is remote WinAppDriver service or not: true to use and false to create default . + Is remote WinAppDriver service or not: true to use + and false to create default . diff --git a/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Configurations/IApplicationProfile.cs b/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Configurations/IApplicationProfile.cs index b52525b..f89a006 100644 --- a/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Configurations/IApplicationProfile.cs +++ b/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Configurations/IApplicationProfile.cs @@ -1,5 +1,4 @@ using System; -using OpenQA.Selenium.Appium.Service; namespace Aquality.WinAppDriver.Configurations { @@ -9,7 +8,8 @@ namespace Aquality.WinAppDriver.Configurations public interface IApplicationProfile { /// - /// Is remote WinAppDriver service or not: true to use and false to create default . + /// Is remote WinAppDriver service or not: true to use + /// and false to create default . /// bool IsRemote { get; } diff --git a/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/ScreenshotProvider.cs b/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/ScreenshotProvider.cs new file mode 100644 index 0000000..7350857 --- /dev/null +++ b/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/ScreenshotProvider.cs @@ -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); + } + } + } +} diff --git a/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/TestWithApplication.cs b/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/TestWithApplication.cs index 57ef01b..18f96d0 100644 --- a/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/TestWithApplication.cs +++ b/Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/TestWithApplication.cs @@ -1,5 +1,6 @@ using Aquality.WinAppDriver.Applications; using NUnit.Framework; +using NUnit.Framework.Interfaces; namespace Aquality.WinAppDriver.Tests { @@ -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(); diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3462f69..876816e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -40,11 +40,6 @@ steps: displayName: 'Publish SonarCloud quality gate results' continueOnError: true -- task: ScreenResolutionUtility@1 - displayName: 'Set up optimal screen resolution' - inputs: - displaySettings: 'optimal' - - task: Windows Application Driver@0 displayName: 'Start WinAppDriver' inputs: From 8d4e86269c3e792061dcd43982f205d815dae3de Mon Sep 17 00:00:00 2001 From: Pavel Anihimovsky Date: Tue, 21 Apr 2020 13:54:21 +0300 Subject: [PATCH 08/10] Add screen resolution task to pipeline --- azure-pipelines.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 876816e..f0123e6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -40,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: From 5c91b8a3404777fd2792a23452c30e060d9ba1ba Mon Sep 17 00:00:00 2001 From: Pavel Anihimovsky Date: Tue, 21 Apr 2020 13:59:51 +0300 Subject: [PATCH 09/10] Fix pipeline --- azure-pipelines.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f0123e6..64c0de3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -41,11 +41,11 @@ steps: continueOnError: true - task: ScreenResolutionUtility@1 - displayName: 'Set up screen resolution 1920x1080' - inputs: - displaySettings: 'specific' - width: '1920' - height: '1080' + displayName: 'Set up screen resolution 1920x1080' + inputs: + displaySettings: 'specific' + width: '1920' + height: '1080' - task: Windows Application Driver@0 displayName: 'Start WinAppDriver' From e805ed3d2b88c03f7371b05dc50ffc4d23e49f17 Mon Sep 17 00:00:00 2001 From: Pavel Anihimovsky Date: Tue, 21 Apr 2020 15:52:34 +0300 Subject: [PATCH 10/10] Remove Meta from ModifierKey enum --- .../src/Aquality.WinAppDriver/Actions/ModifierKey.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Actions/ModifierKey.cs b/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Actions/ModifierKey.cs index 3213e7a..17ae15d 100644 --- a/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Actions/ModifierKey.cs +++ b/Aquality.WinAppDriver/src/Aquality.WinAppDriver/Actions/ModifierKey.cs @@ -31,10 +31,6 @@ public enum ModifierKey /// LeftShift, /// - /// Represents the function key META. - /// - Meta, - /// /// Represents the Shift key. /// Shift