diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index e22c54c..f6e267a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1,2 @@ -* @pavelanihimovsky +* @paveliam +* @mialeska diff --git a/.github/workflows/test-with-allure-report.yml b/.github/workflows/test-with-allure-report.yml index 8177814..03e0566 100644 --- a/.github/workflows/test-with-allure-report.yml +++ b/.github/workflows/test-with-allure-report.yml @@ -24,8 +24,8 @@ jobs: env: BUILD_CONFIGURATION: Release SOLUTION_NAME: Aquality.Selenium.Template/Aquality.Selenium.Template.sln - ALLURE_RESULTS: Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/bin/Release/net6.0/allure-results - ALLURE_NUNIT_RESULTS: Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/bin/Release/net6.0/allure-results + ALLURE_RESULTS: Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/bin/Release/net8.0/allure-results + ALLURE_NUNIT_RESULTS: Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/bin/Release/net8.0/allure-results ENVIRONMENT: ${{ github.event.inputs.environment == '' && 'Stage' || github.event.inputs.environment }} GH_PAGES_URL: https://aquality-automation.github.io/aquality-selenium-dotnet-template concurrency: test-${{ github.event.inputs.environment == '' && 'Stage' || github.event.inputs.environment }} @@ -38,7 +38,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x - name: Install Google Chrome run: | diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Aquality.Selenium.Template.NUnit.csproj b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Aquality.Selenium.Template.NUnit.csproj index 0296e24..9ef054a 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Aquality.Selenium.Template.NUnit.csproj +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Aquality.Selenium.Template.NUnit.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 false @@ -17,12 +17,12 @@ + - - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Extensions/FormExtension.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Extensions/FormExtension.cs index 7383625..dd3e5eb 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Extensions/FormExtension.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Extensions/FormExtension.cs @@ -7,12 +7,12 @@ public static class FormExtensions { public static void AssertIsPresent(this Form form) { - Assert.IsTrue(form.State.WaitForDisplayed(), $"{form.Name} should be presented"); + Assert.That(form.State.WaitForDisplayed(), $"{form.Name} should be presented"); } public static void AssertIsNotPresent(this Form form) { - Assert.IsTrue(form.State.WaitForNotDisplayed(), $"{form.Name} should not be presented"); + Assert.That(form.State.WaitForNotDisplayed(), $"{form.Name} should not be presented"); } } } diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/GlobalSuppressions.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/GlobalSuppressions.cs new file mode 100644 index 0000000..2877c01 --- /dev/null +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/GlobalSuppressions.cs @@ -0,0 +1,8 @@ +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Naming", "VSSpell001:Spell Check", Justification = "", Scope = "namespaceanddescendants", Target = "~N:Aquality.Selenium.Template.NUnit")] diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/ContactUsPageSteps.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/ContactUsPageSteps.cs index aabdf06..928f98e 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/ContactUsPageSteps.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/ContactUsPageSteps.cs @@ -17,7 +17,7 @@ namespace Aquality.Selenium.Template.NUnit.Steps { public class ContactUsPageSteps { - private readonly ContactUsPage contactUsPage = new ContactUsPage(); + private readonly ContactUsPage contactUsPage = new(); private readonly ContactUsInfo contactUsInfo = JsonConvert.DeserializeObject(FileReader.GetTextFromEmbeddedResource(ResourceConstants.PathToContactUserWithInvalidEmail, Assembly.GetCallingAssembly())); [LogStep(StepType.Assertion)] @@ -33,19 +33,19 @@ public void CheckThatTheContactUsFormElementsAreDisplayed() { foreach(ContactUsTextFields name in Enum.GetValues(typeof(ContactUsTextFields))) { - Assert.IsTrue(contactUsPage.IsContactUsTextBoxPresent(name), $"Text field {name} should be displayed"); + Assert.That(contactUsPage.IsContactUsTextBoxPresent(name), $"Text field {name} should be displayed"); } - Assert.IsTrue(contactUsPage.IsTermsCheckBoxExist, "Terms checkBox should be exist"); - Assert.IsTrue(contactUsPage.IsTermsLabelPresent, "Terms label should be displayed"); - Assert.IsTrue(contactUsPage.IsSendAMessageButtonPresent, "Send a message button should be displayed"); - Assert.IsTrue(contactUsPage.IsTitleLabelPresent, "Title should be displayed"); + Assert.That(contactUsPage.IsTermsCheckBoxExist, "Terms checkBox should be exist"); + Assert.That(contactUsPage.IsTermsLabelPresent, "Terms label should be displayed"); + Assert.That(contactUsPage.IsSendAMessageButtonPresent, "Send a message button should be displayed"); + Assert.That(contactUsPage.IsTitleLabelPresent, "Title should be displayed"); }); } [LogStep(StepType.Assertion)] public void CheckThanContactUsTitleIsCorrect() { - Assert.AreEqual(contactUsPage.TitleLabelTextValue, TitleConstants.TitleLabelText, "Title text should be same."); + Assert.That(contactUsPage.TitleLabelTextValue, Is.EqualTo(TitleConstants.TitleLabelText), "Title text should be same."); } [LogStep(StepType.Step)] @@ -64,7 +64,7 @@ public void CheckTermCheckBox() public void CheckTermCheckBoxIsCheckedOrNot(bool isChecked = false) { var expectedStatus = isChecked ? "checked" : "not checked"; - Assert.AreEqual(contactUsPage.IsTermsCheckBoxChecked, isChecked, $"Term CheckBox should be {expectedStatus}"); + Assert.That(contactUsPage.IsTermsCheckBoxChecked, Is.EqualTo(isChecked), $"Term CheckBox should be {expectedStatus}"); } [LogStep(StepType.Step)] @@ -94,7 +94,8 @@ public void CheckThatWarningEmailMessageisPresentOrNot(bool isChecked = false) [LogStep(StepType.Step)] public void CheckThatWarningEmailMessageIsCorrect() { - Assert.AreEqual(contactUsPage.WarningEmailMessageTextValue, ContactUsTextFields.Email.GetEnumDescription(), "Warning email message should be correct."); + Assert.That(contactUsPage.WarningEmailMessageTextValue, Is.EqualTo(ContactUsTextFields.Email.GetEnumDescription()), + "Warning email message should be correct."); } } } diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/CustomImageComparatorSteps.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/CustomImageComparatorSteps.cs index b6be103..b3ead25 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/CustomImageComparatorSteps.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/CustomImageComparatorSteps.cs @@ -23,6 +23,7 @@ public CustomImageComparatorSteps(float customThresholdValue, string modelImageR [LogStep(StepType.Step)] public static SKImage GetExpectedImageFromResourse(string expectedImageResourse) { + AttachmentHelper.AddAttachment(expectedImageResourse); return new FileInfo(expectedImageResourse).ReadImage(); } @@ -30,14 +31,14 @@ public static SKImage GetExpectedImageFromResourse(string expectedImageResourse) public void CheckThatActualAndExpectedImagesAreTheSame(SKImage expectedImage) { var differenceBetweenImages = customImageComparator.Compare(modelOfImage, expectedImage); - Assert.AreEqual(0, differenceBetweenImages, "The images should be the same"); + Assert.That(differenceBetweenImages, Is.Zero, "The images should be the same"); } [LogStep(StepType.Assertion)] public void CheckThatActualAndExpectedImagesAreNotTheSame(SKImage expectedImage) { var differenceBetweenImages = customImageComparator.Compare(modelOfImage, expectedImage); - Assert.AreNotEqual(0, differenceBetweenImages, "The images should not be the same"); + Assert.That(differenceBetweenImages, Is.Not.Zero, "The images should not be the same"); } } } diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/FooterFormSteps.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/FooterFormSteps.cs index 1d3de8d..c72a68b 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/FooterFormSteps.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/FooterFormSteps.cs @@ -7,7 +7,7 @@ namespace Aquality.Selenium.Template.NUnit.Steps { public class FooterFormSteps { - private readonly FooterForm footerForm = new FooterForm(); + private readonly FooterForm footerForm = new(); const float ComparisonThreshold = 0.1f; [LogStep(StepType.Assertion)] @@ -21,9 +21,9 @@ public void CheckVisualElementsPresent() { Assert.Multiple(() => { - Assert.IsTrue(footerForm.IsLogoPresent, "Logo should be displayed"); - Assert.IsTrue(footerForm.IsContactsPresent, "Contacts section should be displayed"); - Assert.IsTrue(footerForm.IsSubscribePresent, "Subscribe section should be displayed"); + Assert.That(footerForm.IsLogoPresent, "Logo should be displayed"); + Assert.That(footerForm.IsContactsPresent, "Contacts section should be displayed"); + Assert.That(footerForm.IsSubscribePresent, "Subscribe section should be displayed"); }); } @@ -37,7 +37,7 @@ public void SaveDump() public void CheckThatTheVisualElementsAreCorrect() { var compareVisualElements = footerForm.Dump.Compare(); - Assert.LessOrEqual(compareVisualElements, ComparisonThreshold, "The footer form should contain the correct visual elements"); + Assert.That(compareVisualElements, Is.LessThanOrEqualTo(ComparisonThreshold), "The footer form should contain the correct visual elements"); } } } diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/MainPageSteps.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/MainPageSteps.cs index 90c30fe..f007d2d 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/MainPageSteps.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/MainPageSteps.cs @@ -10,7 +10,7 @@ namespace Aquality.Selenium.Template.NUnit.Steps { public class MainPageSteps { - private readonly MainPage mainPage = new MainPage(); + private readonly MainPage mainPage = new(); [LogStep(StepType.Assertion)] public void MainPageIsPresent() @@ -21,7 +21,7 @@ public void MainPageIsPresent() [LogStep(StepType.Assertion)] public void AcceptCookiesButtonIsDisplayed() { - Assert.IsTrue(mainPage.IsAcceptCookiesButtonDisplayed, "Accept cookies button should be displayed"); + Assert.That(mainPage.IsAcceptCookiesButtonDisplayed, "Accept cookies button should be displayed"); } [LogStep(StepType.Assertion)] diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/TopBarMenuSteps.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/TopBarMenuSteps.cs index 5e6e279..8f6d801 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/TopBarMenuSteps.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/TopBarMenuSteps.cs @@ -2,15 +2,16 @@ using Aquality.Selenium.Template.NUnit.Extensions; using NUnit.Framework; using Aquality.Selenium.Template.CustomAttributes; +using NUnit.Framework.Legacy; namespace Aquality.Selenium.Template.NUnit.Steps { public class TopBarMenuSteps { - private readonly TopBarMenu topBarMenu = new TopBarMenu(); + private readonly TopBarMenu topBarMenu = new(); private const string ServicesTabItem = "Services"; - private static string[] HeaderTabItems = { "Services", "Approach", "Portfolio", "Blog", "Company" }; - private static string[] ServicesTitleElements = { "Full-cycle testing services", "Quality engineering", "Complete test coverage", "Systems & platforms" }; + private static readonly string[] HeaderTabItems = ["Services", "Industries", "Approach", "Portfolio", "Blog", "Company"]; + private static readonly string[] ServicesTitleElements = ["Full-cycle testing services", "Quality engineering", "Complete test coverage", "Systems & platforms"]; [LogStep(StepType.Assertion)] public void TopBarMenuIsPresent() @@ -27,7 +28,7 @@ public void ClickContactUs() [LogStep(StepType.Assertion)] public void ContactUsButtonIsPresent() { - Assert.IsTrue(topBarMenu.IsContactUsButtonExist, "Contact Us button should be present"); + Assert.That(topBarMenu.IsContactUsButtonExist, "Contact Us button should be present"); } [LogStep(StepType.Assertion)] diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/BaseTest.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/BaseTest.cs index cb0a7df..506dc15 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/BaseTest.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/BaseTest.cs @@ -16,8 +16,7 @@ protected static string ScenarioName private static Logger Logger => Logger.Instance; - private static TestContext.ResultAdapter Result => TestContext.CurrentContext.Result; - private readonly ScreenshotProvider screenshotProvider = new ScreenshotProvider(); + protected static TestContext.ResultAdapter Result => TestContext.CurrentContext.Result; [OneTimeSetUp] public void OneTimeSetUp() @@ -43,10 +42,6 @@ private void LogScenarioResult() Logger.Info($"Scenario [{ScenarioName}] result is {Result.Outcome.Status}!"); if (Result.Outcome.Status != TestStatus.Passed) { - if (AqualityServices.IsBrowserStarted) - { - AttachmentHelper.AddAttachment(screenshotProvider.TakeScreenshot(), "Screenshot"); - } Logger.Error(Result.Message); } Logger.Info(new string('=', 100)); diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/BaseWebTest.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/BaseWebTest.cs index 16f39ef..1636d07 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/BaseWebTest.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/BaseWebTest.cs @@ -1,19 +1,24 @@ -using Allure.Commons; -using Aquality.Selenium.Browsers; +using Aquality.Selenium.Browsers; using Aquality.Selenium.Template.Configurations; +using Aquality.Selenium.Template.Utilities; using NUnit.Allure.Attributes; -using NUnit.Framework; +using NUnit.Framework.Interfaces; namespace Aquality.Selenium.Template.NUnit.Tests { public abstract class BaseWebTest : BaseTest { + private readonly ScreenshotProvider screenshotProvider = new(); - [TearDown] - public void CleanUp() + public override void AfterEach() { + base.AfterEach(); if (AqualityServices.IsBrowserStarted) { + if (Result.Outcome.Status != TestStatus.Passed) + { + AttachmentHelper.AddAttachment(screenshotProvider.TakeScreenshot(), "Screenshot"); + } AqualityServices.Browser.Quit(); } } diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/CustomImageComparatorTest.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/CustomImageComparatorTest.cs index 993e0d5..c7901b6 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/CustomImageComparatorTest.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/CustomImageComparatorTest.cs @@ -11,7 +11,7 @@ namespace Aquality.Selenium.Template.NUnit.Tests public class CustomImageComparatorTest : BaseTest { private const float CustomThresholdValue = 0.1f; - private readonly CustomImageComparatorSteps customImageComparatorSteps = new CustomImageComparatorSteps(CustomThresholdValue, ResourceConstants.ActualTestImage); + private readonly CustomImageComparatorSteps customImageComparatorSteps = new(CustomThresholdValue, ResourceConstants.ActualTestImage); [Test(Description = "TC-0005 Compare 2 images one of which is different")] diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/DemoTest.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/DemoTest.cs index 42f4ffc..c61c9f9 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/DemoTest.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/DemoTest.cs @@ -9,10 +9,10 @@ namespace Aquality.Selenium.Template.NUnit.Tests [AllureSuite("Demo Tests")] public class DemoTest : BaseWebTest { - private readonly TopBarMenuSteps topBarMenuSteps = new TopBarMenuSteps(); - private readonly MainPageSteps mainPageSteps = new MainPageSteps(); - private readonly ContactUsPageSteps contactUsFormSteps = new ContactUsPageSteps(); - private readonly FooterFormSteps footerFormSteps = new FooterFormSteps(); + private readonly TopBarMenuSteps topBarMenuSteps = new(); + private readonly MainPageSteps mainPageSteps = new(); + private readonly ContactUsPageSteps contactUsFormSteps = new(); + private readonly FooterFormSteps footerFormSteps = new(); [SetUp] public new void Setup() diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/MainDemoTest.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/MainDemoTest.cs index cf92ead..2c2d17b 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/MainDemoTest.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Tests/MainDemoTest.cs @@ -9,7 +9,7 @@ namespace Aquality.Selenium.Template.NUnit.Tests [AllureSuite("Main Page Demo Test")] public class MainDemoTest : BaseWebTest { - private readonly MainPageSteps mainPageSteps = new MainPageSteps(); + private readonly MainPageSteps mainPageSteps = new(); [SetUp] public new void Setup() diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Aquality.Selenium.Template.SpecFlow.csproj b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Aquality.Selenium.Template.SpecFlow.csproj index 06eecc5..e48aaa7 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Aquality.Selenium.Template.SpecFlow.csproj +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Aquality.Selenium.Template.SpecFlow.csproj @@ -1,23 +1,28 @@  - net6.0 + net8.0 true false - + + + + + + + - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - @@ -30,9 +35,6 @@ Always - - Always - Always diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/GlobalSuppressions.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/GlobalSuppressions.cs new file mode 100644 index 0000000..399d222 --- /dev/null +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/GlobalSuppressions.cs @@ -0,0 +1,8 @@ +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Naming", "VSSpell001:Spell Check", Justification = "", Scope = "namespaceanddescendants", Target = "~N:Aquality.Selenium.Template.SpecFlow")] diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Hooks/BrowserHooks.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Hooks/BrowserHooks.cs index 5ef46b5..1c1bcac 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Hooks/BrowserHooks.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Hooks/BrowserHooks.cs @@ -9,14 +9,9 @@ namespace Aquality.Selenium.Template.SpecFlow.Hooks { [Binding] - public class BrowserHooks + public class BrowserHooks(ScreenshotProvider screenshotProvider) { - private readonly ScreenshotProvider screenshotProvider; - - public BrowserHooks(ScreenshotProvider screenshotProvider) - { - this.screenshotProvider = screenshotProvider; - } + private readonly ScreenshotProvider screenshotProvider = screenshotProvider; [AfterScenario(Order = 0)] public void AttachArtifacts() diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Hooks/PluginsHooks.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Hooks/PluginsHooks.cs index d39a1a4..b283dd1 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Hooks/PluginsHooks.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Hooks/PluginsHooks.cs @@ -1,4 +1,4 @@ -using Allure.Commons; +using Allure.Net.Commons; using Aquality.Selenium.Browsers; using Aquality.Selenium.Template.Browsers; using AqualityTracking.Integrations.Core; @@ -11,11 +11,8 @@ namespace Aquality.Selenium.Template.SpecFlow.Hooks [Binding] public class PluginsHooks { - private readonly ScenarioContext context; - - public PluginsHooks(ScenarioContext context) + public PluginsHooks() { - this.context = context; } [BeforeFeature] @@ -27,8 +24,7 @@ public static void RegisterCustomStartup() [AfterScenario(Order = -1)] public void UpdateAllureTestCaseName() { - context.TryGetValue(out TestResult testresult); - AllureLifecycle.Instance.UpdateTestCase(testresult.uuid, testCase => + AllureLifecycle.Instance.UpdateTestCase(testCase => { testCase.name += GetScenarioNameSuffix(); testCase.historyId = TestContext.CurrentContext.Test.FullName; diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/API/Common/ResponseSteps.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/API/Common/ResponseSteps.cs index b8c4234..1794ffe 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/API/Common/ResponseSteps.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/API/Common/ResponseSteps.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Schema; using NUnit.Framework; +using NUnit.Framework.Legacy; using RestSharp; using System; using System.Collections.Generic; @@ -12,14 +13,9 @@ namespace Aquality.Selenium.Template.SpecFlow.StepDefinitions.API.Common { [Binding] - public class ResponseSteps + public class ResponseSteps(ScenarioContext scenarioContext) { - private readonly ScenarioContext scenarioContext; - - public ResponseSteps(ScenarioContext scenarioContext) - { - this.scenarioContext = scenarioContext; - } + private readonly ScenarioContext scenarioContext = scenarioContext; [Then(@"the status code of the '(.*response.*)' is '(\d*)'")] public static void StatusCodeOfResponseIs(RestResponse response, int statusCode) @@ -45,17 +41,15 @@ public static void CheckFieldInResponse(string fieldName, object expectedValue, public static void AssertResponseSchemaIsValid(RestResponse response, string schemaName) { var schemaPath = Path.Combine(AppContext.BaseDirectory, "Resources", "JsonSchemas", $"{schemaName}.json"); - using (StreamReader file = File.OpenText(schemaPath)) - using (JsonTextReader reader = new JsonTextReader(file)) + using StreamReader file = File.OpenText(schemaPath); + using JsonTextReader reader = new(file); + JSchema schema = JSchema.Load(reader, new JSchemaReaderSettings { - JSchema schema = JSchema.Load(reader, new JSchemaReaderSettings - { - Resolver = new JSchemaUrlResolver(), - BaseUri = new Uri(schemaPath) - }); - AttachmentHelper.AddAttachmentAsJson("json schema", schema); - Assert.That(response.GetBodyAsJson().IsValid(schema), "Json schema should match to expected"); - } + Resolver = new JSchemaUrlResolver(), + BaseUri = new Uri(schemaPath) + }); + AttachmentHelper.AddAttachmentAsJson("json schema", schema); + Assert.That(response.GetBodyAsJson().IsValid(schema), "Json schema should match to expected"); } diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/API/GitHub/RequestSteps.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/API/GitHub/RequestSteps.cs index 9751550..d33a47a 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/API/GitHub/RequestSteps.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/API/GitHub/RequestSteps.cs @@ -5,17 +5,10 @@ namespace Aquality.Selenium.Template.SpecFlow.StepDefinitions.API.GitHub { [Binding] - public class RequestSteps + public class RequestSteps(RequestHandler requestHandler, ScenarioContext scenarioContext) { - private readonly RequestHandler requestHandler; - private readonly ScenarioContext scenarioContext; - - public RequestSteps(RequestHandler requestHandler, ScenarioContext scenarioContext) - { - this.requestHandler = requestHandler; - this.scenarioContext = scenarioContext; - } - + private readonly RequestHandler requestHandler = requestHandler; + private readonly ScenarioContext scenarioContext = scenarioContext; [When(@"I send GET '/([\w-/]+)' request to github with saving the '(.*response.*)'")] [When(@"I send GET request to github endpoint saved as '(.*)' with saving the '(.*response.*)'")] diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/API/GitHub/UserSteps.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/API/GitHub/UserSteps.cs index 3f9c80b..7968338 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/API/GitHub/UserSteps.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/API/GitHub/UserSteps.cs @@ -7,15 +7,9 @@ namespace Aquality.Selenium.Template.SpecFlow.StepDefinitions.API.GitHub { [Binding] - public class UserSteps + public class UserSteps(ScenarioContext scenarioContext) { - private readonly ScenarioContext scenarioContext; - - public UserSteps(ScenarioContext scenarioContext) - { - this.scenarioContext = scenarioContext; - } - + private readonly ScenarioContext scenarioContext = scenarioContext; [When(@"I save the user from the '(.*response.*)' as '(.*)'")] public void SaveTheUserFromTheResponse(RestResponse response, string key) @@ -28,7 +22,7 @@ public void CheckUsersAreDifferent(string user1Key, string user2Key) { var user1 = scenarioContext.Get(user1Key); var user2 = scenarioContext.Get(user2Key); - Assert.AreNotEqual(user1, user2, "Users should not be equal"); + Assert.That(user1, Is.Not.EqualTo(user2), "Users should not be equal"); } } } diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/UI/ContactUsPageSteps.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/UI/ContactUsPageSteps.cs index eddcfff..39a293c 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/UI/ContactUsPageSteps.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/UI/ContactUsPageSteps.cs @@ -6,14 +6,9 @@ namespace Aquality.Selenium.Template.SpecFlow.StepDefinitions.UI { [Binding] - public class ContactUsPageSteps + public class ContactUsPageSteps(ContactUsPage contactUsPage) { - private readonly ContactUsPage contactUsPage; - - public ContactUsPageSteps(ContactUsPage contactUsPage) - { - this.contactUsPage = contactUsPage; - } + private readonly ContactUsPage contactUsPage = contactUsPage; [When(@"I accept Privacy and Cookies Policy")] public void IAcceptPrivacyAndCookiesPolicy() @@ -45,13 +40,13 @@ public void IClickSendButton() [Then(@"Contact us page is opened")] public void ContactUsPageIsOpened() { - Assert.IsTrue(contactUsPage.State.WaitForDisplayed(), "Contact us page should be opened"); + Assert.That(contactUsPage.State.WaitForDisplayed(), "Contact us page should be opened"); } [Then(@"Notification about empty fields is present")] public void ThenNotificationAboutEmptyFieldsIsPresent() { - Assert.IsTrue(contactUsPage.IsEmailValidationMessagePresent, + Assert.That(contactUsPage.IsEmailValidationMessagePresent, "Email validation message should be displayed"); } diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/UI/MainPageSteps.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/UI/MainPageSteps.cs index 0fa0b3c..b5a9087 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/UI/MainPageSteps.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/StepDefinitions/UI/MainPageSteps.cs @@ -7,16 +7,10 @@ namespace Aquality.Selenium.Template.SpecFlow.StepDefinitions.UI { [Binding] - public class MainPageSteps + public class MainPageSteps(MainPage mainPage, TopBarMenu topBarMenu) { - private readonly MainPage mainPage; - private readonly TopBarMenu topBarMenu; - - public MainPageSteps(MainPage mainPage, TopBarMenu topBarMenu) - { - this.mainPage = mainPage; - this.topBarMenu = topBarMenu; - } + private readonly MainPage mainPage = mainPage; + private readonly TopBarMenu topBarMenu = topBarMenu; [Given(@"Main page is opened")] public static void MainPageIsOpened() diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Transformations/API/ContextTransformations.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Transformations/API/ContextTransformations.cs index b6142ab..af35a95 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Transformations/API/ContextTransformations.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Transformations/API/ContextTransformations.cs @@ -5,14 +5,9 @@ namespace Aquality.Selenium.Template.SpecFlow.Transformations.API { [Binding] - public class ContextTransformations + public class ContextTransformations(ScenarioContext scenarioContext) { - private readonly ScenarioContext scenarioContext; - - public ContextTransformations(ScenarioContext scenarioContext) - { - this.scenarioContext = scenarioContext; - } + private readonly ScenarioContext scenarioContext = scenarioContext; [StepArgumentTransformation("(.*response.*)")] public RestResponse Response(string key) diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/allureConfig.json b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/allureConfig.json index 0aef4c9..a796ef5 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/allureConfig.json +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/allureConfig.json @@ -1,4 +1,5 @@ { + "$schema": "https://raw.githubusercontent.com/allure-framework/allure-csharp/2.11.0/Allure.SpecFlowPlugin/Schemas/allureConfig.schema.json", "allure": { "directory": "allure-results", "links": [ diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template/Aquality.Selenium.Template.csproj b/Aquality.Selenium.Template/Aquality.Selenium.Template/Aquality.Selenium.Template.csproj index d89928b..20a02e9 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template/Aquality.Selenium.Template.csproj +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template/Aquality.Selenium.Template.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 @@ -15,18 +15,22 @@ - - - + + + - - - - + + + - + + + + + Always + Always diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template/CustomAttributes/LogStepAttribute.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template/CustomAttributes/LogStepAttribute.cs index 011dac8..33a3071 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template/CustomAttributes/LogStepAttribute.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template/CustomAttributes/LogStepAttribute.cs @@ -5,13 +5,8 @@ namespace Aquality.Selenium.Template.CustomAttributes { [Injection(typeof(TraceAspect))] [AttributeUsage(AttributeTargets.Method, Inherited = false)] - public class LogStepAttribute : Attribute + public class LogStepAttribute(StepType stepType) : Attribute { - public StepType StepType { get; } - - public LogStepAttribute(StepType stepType) - { - StepType = stepType; - } + public StepType StepType { get; } = stepType; } } diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template/CustomAttributes/TraceAspect.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template/CustomAttributes/TraceAspect.cs index 53d63d7..ca71ffc 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template/CustomAttributes/TraceAspect.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template/CustomAttributes/TraceAspect.cs @@ -3,8 +3,8 @@ using System.Reflection; using Aquality.Selenium.Core.Logging; using Humanizer; -using Allure.Commons; -using NUnit.Allure.Core.Steps; +using Allure.Net.Commons; +using Allure.Net.Commons.Steps; namespace Aquality.Selenium.Template.CustomAttributes { @@ -26,7 +26,7 @@ public object LogMethodEntry( var stepName = name.Humanize(); if (arguments.Length > 0) { - stepName = $"{stepName} method with parameters: {string.Join("-", arguments)}"; + stepName = $"{stepName} with parameters: {string.Join("-", arguments)}"; } LogStep(stepName, classType.Name, logLevel.ToString()); @@ -39,7 +39,7 @@ public object LogMethodEntry( object result; try { - AllureLifecycle.Instance.StartStep(Guid.NewGuid().ToString(), stepResult); + AllureLifecycle.Instance.StartStep(stepResult); result = method(arguments); AllureLifecycle.Instance.StopStep(step => stepResult.status = Status.passed); } diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template/Elements/CustomTextBox.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template/Elements/CustomTextBox.cs index df9192e..517565c 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template/Elements/CustomTextBox.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template/Elements/CustomTextBox.cs @@ -4,12 +4,8 @@ namespace Aquality.Selenium.Template.Elements { - public class CustomTextBox : TextBox + public class CustomTextBox(By locator, string name, ElementState state) : TextBox(locator, name, state) { - public CustomTextBox(By locator, string name, ElementState state) : base(locator, name, state) - { - } - public new string Text => Value; } } diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template/GlobalSuppressions.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template/GlobalSuppressions.cs new file mode 100644 index 0000000..8f49fd1 --- /dev/null +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template/GlobalSuppressions.cs @@ -0,0 +1,8 @@ +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Naming", "VSSpell001:Spell Check", Justification = "", Scope = "namespaceanddescendants", Target = "~N:Aquality.Selenium.Template")] diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template/Logging/AllureBasedLocalizedLogger.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template/Logging/AllureBasedLocalizedLogger.cs index 6434eee..a3b01e2 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template/Logging/AllureBasedLocalizedLogger.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template/Logging/AllureBasedLocalizedLogger.cs @@ -1,4 +1,4 @@ -using Allure.Commons; +using Allure.Net.Commons; using Aquality.Selenium.Core.Configurations; using Aquality.Selenium.Core.Localization; using Aquality.Selenium.Core.Logging; @@ -6,15 +6,9 @@ namespace Aquality.Selenium.Template.Logging { - public class AllureBasedLocalizedLogger : LocalizedLogger, ILocalizedLogger + public class AllureBasedLocalizedLogger(ILocalizationManager localizationManager, Logger logger, ILoggerConfiguration configuration) : LocalizedLogger(localizationManager, logger, configuration), ILocalizedLogger { - private readonly ILocalizationManager localizationManager; - - public AllureBasedLocalizedLogger(ILocalizationManager localizationManager, Logger logger, ILoggerConfiguration configuration) - : base(localizationManager, logger, configuration) - { - this.localizationManager = localizationManager; - } + private readonly ILocalizationManager localizationManager = localizationManager; public new void InfoElementAction(string elementType, string elementName, string messageKey, params object[] args) { diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template/Logging/AllureExtensions.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template/Logging/AllureExtensions.cs index 1343aea..5245ee1 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template/Logging/AllureExtensions.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template/Logging/AllureExtensions.cs @@ -1,4 +1,4 @@ -using Allure.Commons; +using Allure.Net.Commons; using System; using System.Runtime.CompilerServices; @@ -16,11 +16,10 @@ public static void WrapInStep(this AllureLifecycle lifecycle, Action action, str stepName = callerName; } - var id = Guid.NewGuid().ToString(); var stepResult = new StepResult { name = stepName }; try { - lifecycle.StartStep(id, stepResult); + lifecycle.StartStep(stepResult); action.Invoke(); lifecycle.StopStep(step => stepResult.status = Status.passed); } diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Resources/aqualityTracking.json b/Aquality.Selenium.Template/Aquality.Selenium.Template/Resources/aqualityTracking.json similarity index 100% rename from Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Resources/aqualityTracking.json rename to Aquality.Selenium.Template/Aquality.Selenium.Template/Resources/aqualityTracking.json diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template/Resources/settings.azure.json b/Aquality.Selenium.Template/Aquality.Selenium.Template/Resources/settings.azure.json index 4d7b536..37c66dc 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template/Resources/settings.azure.json +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template/Resources/settings.azure.json @@ -7,9 +7,7 @@ "driverSettings": { "chrome": { - "webDriverVersion": "MatchingBrowser", "capabilities": { - "enableVNC": true, "unhandledPromptBehavior": "default" }, "options": { @@ -29,9 +27,7 @@ "pageLoadStrategy": "Normal" }, "firefox": { - "webDriverVersion": "Latest", "capabilities": { - "enableVNC": true, "unhandledPromptBehavior": "default" }, "options": { @@ -52,8 +48,6 @@ "startArguments": [] }, "iexplorer": { - "webDriverVersion": "Latest", - "systemArchitecture": "X32", "capabilities": { "ignoreProtectedModeSettings": true, "unhandledPromptBehavior": "default" @@ -63,9 +57,7 @@ "startArguments": [] }, "edge": { - "webDriverVersion": "Latest", "capabilities": { - "enableVNC": true }, "options": { "intl.accept_languages": "en", @@ -86,7 +78,6 @@ "opera": { "webDriverVersion": "Latest", "capabilities": { - "enableVNC": true, "unhandledPromptBehavior": "ignore" }, "options": { @@ -99,10 +90,8 @@ "startArguments": [] }, "yandex": { - "webDriverVersion": "94.0.4606.41", "binaryLocation": "%USERPROFILE%\\AppData\\Local\\Yandex\\YandexBrowser\\Application\\browser.exe", "capabilities": { - "enableVNC": true, "unhandledPromptBehavior": "ignore" }, "options": { @@ -120,7 +109,7 @@ "timeoutImplicit": 0, "timeoutCondition": 30, "timeoutScript": 10, - "timeoutPageLoad": 15, + "timeoutPageLoad": 20, "timeoutPollingInterval": 300, "timeoutCommand": 60, "timeoutElementAppear": 15 diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template/Resources/settings.json b/Aquality.Selenium.Template/Aquality.Selenium.Template/Resources/settings.json index cf158b7..1291adf 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template/Resources/settings.json +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template/Resources/settings.json @@ -7,11 +7,12 @@ "driverSettings": { "chrome": { - "webDriverVersion": "MatchingBrowser", - "capabilities": { - "enableVNC": true, - "unhandledPromptBehavior": "default" + "capabilities": { + "selenoid:options": { + "enableVNC": true }, + "unhandledPromptBehavior": "default" + }, "options": { "intl.accept_languages": "en", "safebrowsing.enabled": "true", @@ -31,9 +32,7 @@ "pageLoadStrategy": "Normal" }, "firefox": { - "webDriverVersion": "Latest", "capabilities": { - "enableVNC": true, "unhandledPromptBehavior": "default" }, "options": { @@ -54,8 +53,6 @@ "startArguments": [] }, "iexplorer": { - "webDriverVersion": "Latest", - "systemArchitecture": "X32", "capabilities": { "ignoreProtectedModeSettings": true, "unhandledPromptBehavior": "default" @@ -65,9 +62,7 @@ "startArguments": [] }, "edge": { - "webDriverVersion": "Latest", "capabilities": { - "enableVNC": true }, "options": { "intl.accept_languages": "en", @@ -85,23 +80,23 @@ }, "startArguments": [] }, - "opera": { - "webDriverVersion": "Latest", - "capabilities": { - "enableVNC": true, - "unhandledPromptBehavior": "ignore" - }, - "options": { - "intl.accept_languages": "en", - "safebrowsing.enabled": "true", - "profile.default_content_settings.popups": "0", - "disable-popup-blocking": "true", - "download.prompt_for_download": "false" - }, - "startArguments": [] + "opera": { + "webDriverVersion": "Latest", + "binaryLocation": "%USERPROFILE%\\AppData\\Local\\Programs\\Opera\\launcher.exe", + "capabilities": { + "unhandledPromptBehavior": "ignore" + }, + "options": { + "intl.accept_languages": "en", + "safebrowsing.enabled": "true", + "profile.default_content_settings.popups": "0", + "disable-popup-blocking": "true", + "download.prompt_for_download": "false" }, + "excludedArguments": [ "enable-automation" ], + "startArguments": [ "--remote-debugging-port=9222", "--no-sandbox", "--disable-dev-shm-usage" ] + }, "yandex": { - "webDriverVersion": "94.0.4606.41", "binaryLocation": "%USERPROFILE%\\AppData\\Local\\Yandex\\YandexBrowser\\Application\\browser.exe", "capabilities": { "enableVNC": true, @@ -122,7 +117,7 @@ "timeoutImplicit": 0, "timeoutCondition": 30, "timeoutScript": 10, - "timeoutPageLoad": 15, + "timeoutPageLoad": 20, "timeoutPollingInterval": 300, "timeoutCommand": 60, "timeoutElementAppear": 15 diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template/Utilities/AttachmentHelper.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template/Utilities/AttachmentHelper.cs index e00596a..efff085 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template/Utilities/AttachmentHelper.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template/Utilities/AttachmentHelper.cs @@ -1,4 +1,4 @@ -using Allure.Commons; +using Allure.Net.Commons; using AqualityTracking.Integrations.Core; using Newtonsoft.Json; using NUnit.Framework; @@ -15,14 +15,14 @@ public static class AttachmentHelper public static void AddAttachment(string pathToFile, string name = null) { TestContext.AddTestAttachment(pathToFile); - AllureLifecycle.Instance.AddAttachment(pathToFile, name); + AllureApi.AddAttachment(pathToFile, name); AqualityTrackingLifecycle.Instance.AddAttachment(pathToFile); } public static void AddAttachment(string name, string type, string content, string fileExtension = "") { var utfBytes = Encoding.UTF8.GetBytes(content); - AllureLifecycle.Instance.AddAttachment(name, type, utfBytes, fileExtension); + AllureApi.AddAttachment(name, type, utfBytes, fileExtension); var filePath = $"{name}_{DateTime.Now:yyyyMMdd-HHmmss-ffff}{fileExtension}"; File.WriteAllBytes(filePath, utfBytes); AqualityTrackingLifecycle.Instance.AddAttachment(filePath); diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template/Utilities/CustomImageComparator.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template/Utilities/CustomImageComparator.cs index c925d76..6b458de 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template/Utilities/CustomImageComparator.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template/Utilities/CustomImageComparator.cs @@ -20,13 +20,13 @@ public float Compare(SKImage firstImage, SKImage secondImage, float? threshold = } } - internal class VisualizationConfiguration : IVisualizationConfiguration + internal class VisualizationConfiguration(float defaultThreshold, int comparisonWidth, int comparisonHeight) : IVisualizationConfiguration { - public float DefaultThreshold { get; } + public float DefaultThreshold { get; } = defaultThreshold; - public int ComparisonWidth { get; } + public int ComparisonWidth { get; } = comparisonWidth; - public int ComparisonHeight { get; } + public int ComparisonHeight { get; } = comparisonHeight; /// /// This field is not implemented. This field is needed to compare Image Dumps. @@ -42,12 +42,5 @@ internal class VisualizationConfiguration : IVisualizationConfiguration /// This field is not implemented. This field is needed to compare Image Dumps. /// public int MaxFullFileNameLength => throw new System.NotImplementedException(); - - public VisualizationConfiguration(float defaultThreshold, int comparisonWidth, int comparisonHeight) - { - DefaultThreshold = defaultThreshold; - ComparisonWidth = comparisonWidth; - ComparisonHeight = comparisonHeight; - } } } diff --git a/Aquality.Selenium.Template/Aquality.Selenium.Template/Utilities/RequestHandler.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template/Utilities/RequestHandler.cs index 781ab7d..11884d0 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template/Utilities/RequestHandler.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template/Utilities/RequestHandler.cs @@ -7,7 +7,7 @@ namespace Aquality.Selenium.Template.Utilities { public class RequestHandler { - private readonly RestClient restClient = new RestClient(Configuration.ApiUrl); + private readonly RestClient restClient = new(Configuration.ApiUrl); public RestResponse Execute(RestRequest request) { diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ba99de3..1d71d75 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -22,10 +22,10 @@ steps: sonar.coverage.exclusions=**/** - task: UseDotNet@2 - displayName: Use .NET 6.0 + displayName: Use .NET 8.0 inputs: packageType: 'sdk' - version: '6.0.x' + version: '8.0.x' - task: DotNetCoreCLI@2 displayName: 'Build whole solution'