From cb8391f0e65ffa7e4f8cea33f8625d18b6d8cf3f Mon Sep 17 00:00:00 2001 From: Aliaksej Mialeshka Date: Tue, 23 Jan 2024 18:23:49 +0100 Subject: [PATCH] Update to NUnit 4 Update to .Net 8, update coding style. --- .github/CODEOWNERS | 2 ++ .github/workflows/test-with-allure-report.yml | 4 +-- .../Aquality.Selenium.Template.NUnit.csproj | 2 +- .../Extensions/FormExtension.cs | 4 +-- .../Steps/ContactUsPageSteps.cs | 19 +++++++------ .../Steps/CustomImageComparatorSteps.cs | 4 +-- .../Steps/FooterFormSteps.cs | 10 +++---- .../Steps/MainPageSteps.cs | 4 +-- .../Steps/TopBarMenuSteps.cs | 7 +++-- ...Aquality.Selenium.Template.SpecFlow.csproj | 3 +- .../Hooks/BrowserHooks.cs | 9 ++---- .../API/Common/ResponseSteps.cs | 28 ++++++++----------- .../API/GitHub/RequestSteps.cs | 13 ++------- .../StepDefinitions/API/GitHub/UserSteps.cs | 12 ++------ .../StepDefinitions/UI/ContactUsPageSteps.cs | 13 +++------ .../StepDefinitions/UI/MainPageSteps.cs | 12 ++------ .../API/ContextTransformations.cs | 9 ++---- .../Aquality.Selenium.Template.csproj | 2 +- .../CustomAttributes/LogStepAttribute.cs | 9 ++---- .../Elements/CustomTextBox.cs | 6 +--- .../Logging/AllureBasedLocalizedLogger.cs | 10 ++----- .../Resources/settings.azure.json | 2 +- .../Resources/settings.json | 2 +- .../Utilities/CustomImageComparator.cs | 15 +++------- .../Utilities/RequestHandler.cs | 2 +- 25 files changed, 73 insertions(+), 130 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index e22c54c..0aec0d0 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1,3 @@ * @pavelanihimovsky +* @mialeska +* @mpushnikA1QA diff --git a/.github/workflows/test-with-allure-report.yml b/.github/workflows/test-with-allure-report.yml index f9ce486..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 }} 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 7eb22a8..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 @@ -20,7 +20,7 @@ - + all 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/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 102bd85..b3ead25 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/CustomImageComparatorSteps.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template.NUnit/Steps/CustomImageComparatorSteps.cs @@ -31,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 c45e153..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,6 +2,7 @@ using Aquality.Selenium.Template.NUnit.Extensions; using NUnit.Framework; using Aquality.Selenium.Template.CustomAttributes; +using NUnit.Framework.Legacy; namespace Aquality.Selenium.Template.NUnit.Steps { @@ -9,8 +10,8 @@ public class TopBarMenuSteps { private readonly TopBarMenu topBarMenu = new(); private const string ServicesTabItem = "Services"; - 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" }; + 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.SpecFlow/Aquality.Selenium.Template.SpecFlow.csproj b/Aquality.Selenium.Template/Aquality.Selenium.Template.SpecFlow/Aquality.Selenium.Template.SpecFlow.csproj index 7c99975..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 @@ -8,6 +8,7 @@ + @@ -15,7 +16,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive 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/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/Aquality.Selenium.Template.csproj b/Aquality.Selenium.Template/Aquality.Selenium.Template/Aquality.Selenium.Template.csproj index f5577fd..20a02e9 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template/Aquality.Selenium.Template.csproj +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template/Aquality.Selenium.Template.csproj @@ -20,7 +20,7 @@ - + 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/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/Logging/AllureBasedLocalizedLogger.cs b/Aquality.Selenium.Template/Aquality.Selenium.Template/Logging/AllureBasedLocalizedLogger.cs index c9e9f31..a3b01e2 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template/Logging/AllureBasedLocalizedLogger.cs +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template/Logging/AllureBasedLocalizedLogger.cs @@ -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/Resources/settings.azure.json b/Aquality.Selenium.Template/Aquality.Selenium.Template/Resources/settings.azure.json index 292794a..37c66dc 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template/Resources/settings.azure.json +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template/Resources/settings.azure.json @@ -109,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 d6e0133..1291adf 100644 --- a/Aquality.Selenium.Template/Aquality.Selenium.Template/Resources/settings.json +++ b/Aquality.Selenium.Template/Aquality.Selenium.Template/Resources/settings.json @@ -117,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/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) {