diff --git a/Test/UITest/SpecFlowProjectBDD/Features/AddSubsidiaryPlatform.feature b/Test/UITest/SpecFlowProjectBDD/Features/AddSubsidiaryPlatform.feature new file mode 100644 index 00000000..1ad3a668 --- /dev/null +++ b/Test/UITest/SpecFlowProjectBDD/Features/AddSubsidiaryPlatform.feature @@ -0,0 +1,54 @@ +Feature: ManagePlatforms +Link to a feature: https://hous-hpb.atlassian.net/browse/DSS-226 + +@LandingPage +Scenario: AddSubsidiaryPlatform +#User Authentication + Given that I am an authenticated User "" and the expected result is "" and I am a "" user + Then I am directed to the Landing Page + +#Select Manage Platforms + When I click on the Manage Platforms button + + Then I should be presented with a list of platforms and sub-platforms + +#Select Platform + When I click the edit button for a platform + Then I amd directed to the Platform view page + +#Add sub-platform + When I click on the add subsidiary platform button + Then I should be presented with the Add Platform page + + +#Input fields + Then I should see a form with the required input fields for creating a sub-platform + + #Platform Name + #Platform Code + #Primary Email for Non-Compliance Notices + #Primary Email for Takedown Request Letters + #Secondary Email for Non-Compliance Notices + #Secondary Email for Takedown Request Letters + + +#Enter values for Input Fields + When I fill in valid values for the input fields + Then the Save button should be enabled + +#Click Save button to create sub platform + When I click the Save button + Then the sub platform should be created + Then the sub platform should be a child of the parent platform + + + +Examples: + | UserName | UserType | Environment | ExpectedResult | + | CEUATST | ceu_admin | all | pass | + + + + + + diff --git a/Test/UITest/SpecFlowProjectBDD/Features/AddSubsidiaryPlatform.feature.cs b/Test/UITest/SpecFlowProjectBDD/Features/AddSubsidiaryPlatform.feature.cs new file mode 100644 index 00000000..f643966e --- /dev/null +++ b/Test/UITest/SpecFlowProjectBDD/Features/AddSubsidiaryPlatform.feature.cs @@ -0,0 +1,154 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (https://www.specflow.org/). +// SpecFlow Version:3.9.0.0 +// SpecFlow Generator Version:3.9.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +#pragma warning disable +namespace SpecFlowProjectBDD.Features +{ + using TechTalk.SpecFlow; + using System; + using System.Linq; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.9.0.0")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("ManagePlatforms")] + public partial class ManagePlatformsFeature + { + + private TechTalk.SpecFlow.ITestRunner testRunner; + + private static string[] featureTags = ((string[])(null)); + +#line 1 "AddSubsidiaryPlatform.feature" +#line hidden + + [NUnit.Framework.OneTimeSetUpAttribute()] + public virtual void FeatureSetup() + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Features", "ManagePlatforms", "Link to a feature: https://hous-hpb.atlassian.net/browse/DSS-226", ProgrammingLanguage.CSharp, featureTags); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.OneTimeTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public void TestTearDown() + { + testRunner.OnScenarioEnd(); + } + + public void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioInitialize(scenarioInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); + } + + public void ScenarioStart() + { + testRunner.OnScenarioStart(); + } + + public void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("AddSubsidiaryPlatform")] + [NUnit.Framework.CategoryAttribute("LandingPage")] + [NUnit.Framework.TestCaseAttribute("CEUATST", "ceu_admin", "all", "pass", null)] + public void AddSubsidiaryPlatform(string userName, string userType, string environment, string expectedResult, string[] exampleTags) + { + string[] @__tags = new string[] { + "LandingPage"}; + if ((exampleTags != null)) + { + @__tags = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Concat(@__tags, exampleTags)); + } + string[] tagsOfScenario = @__tags; + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + argumentsOfScenario.Add("UserName", userName); + argumentsOfScenario.Add("UserType", userType); + argumentsOfScenario.Add("Environment", environment); + argumentsOfScenario.Add("ExpectedResult", expectedResult); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("AddSubsidiaryPlatform", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 5 +this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 7 + testRunner.Given(string.Format("that I am an authenticated User \"{0}\" and the expected result is \"{1}\" and I am a" + + " \"{2}\" user", userName, expectedResult, userType), ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 8 + testRunner.Then("I am directed to the Landing Page", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 11 + testRunner.When("I click on the Manage Platforms button", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 13 + testRunner.Then("I should be presented with a list of platforms and sub-platforms", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 16 + testRunner.When("I click the edit button for a platform", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 17 + testRunner.Then("I amd directed to the Platform view page", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 20 + testRunner.When("I click on the add subsidiary platform button", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 21 + testRunner.Then("I should be presented with the Add Platform page", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 25 + testRunner.Then("I should see a form with the required input fields for creating a sub-platform", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 36 + testRunner.When("I fill in valid values for the input fields", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 37 + testRunner.Then("the Save button should be enabled", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 40 + testRunner.When("I click the Save button", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 41 + testRunner.Then("the sub platform should be created", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden +#line 42 + testRunner.Then("the sub platform should be a child of the parent platform", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/Test/UITest/SpecFlowProjectBDD/Hooks/SeleniumSpecFlowHooks.cs b/Test/UITest/SpecFlowProjectBDD/Hooks/SeleniumSpecFlowHooks.cs index 423b5897..77e6db46 100644 --- a/Test/UITest/SpecFlowProjectBDD/Hooks/SeleniumSpecFlowHooks.cs +++ b/Test/UITest/SpecFlowProjectBDD/Hooks/SeleniumSpecFlowHooks.cs @@ -5,12 +5,14 @@ namespace SpecFlowProjectBDD.Hooks { + /// + /// Hooks for scenario and test setup/teardown. Currently only uses Chrome and will need to be modified for other browser types + /// [Binding] public class SeleniumSpecFlowHooks { private int driverProcessPID; - private Process[] driverProcessess1; - private Process[] driverProcessess2; + private Process[] driverProcessess; protected IObjectContainer _Container; public SeleniumSpecFlowHooks(IObjectContainer container) @@ -21,18 +23,7 @@ public SeleniumSpecFlowHooks(IObjectContainer container) [BeforeScenario(Order = 3)] public void SetupDrivers() { - //check for any Chromedrivers running as a disconnected process rather than under VS. Having running drivers will cause the current test to fail - driverProcessess1 = Process.GetProcessesByName("chromedriver.exe"); - - if (driverProcessess1.Length != 0) - { - //cleanup old drivers - foreach (var driverProcess in driverProcessess1) - { - driverProcess.Kill(); - } - } - + CleanupDrivers(); SeleniumDriver webDriver = new SeleniumDriver(SeleniumDriver.DRIVERTYPE.CHROME); webDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); @@ -42,7 +33,15 @@ public void SetupDrivers() [AfterScenario(Order = 3)] public void DestroyDrivers() { - var webDriver = _Container.Resolve(); + SeleniumDriver? webDriver = null; + try + { + webDriver = _Container.Resolve(); + } + catch (BoDi.ObjectContainerException ex) + { + CleanupDrivers(); + } if (webDriver == null) return; @@ -51,5 +50,21 @@ public void DestroyDrivers() webDriver.Dispose(); } + private void CleanupDrivers() + { + //check for any Chromedrivers running as a disconnected process rather than under VS. Having running drivers will cause the current test to fail + driverProcessess = Process.GetProcessesByName("chromedriver"); + + if (driverProcessess.Length != 0) + { + //cleanup old drivers + foreach (var driverProcess in driverProcessess) + { + driverProcess.Kill(); + } + } + } + + } } diff --git a/Test/UITest/SpecFlowProjectBDD/SpecFlowProjectBDD.csproj b/Test/UITest/SpecFlowProjectBDD/SpecFlowProjectBDD.csproj index baa11895..690a7547 100644 --- a/Test/UITest/SpecFlowProjectBDD/SpecFlowProjectBDD.csproj +++ b/Test/UITest/SpecFlowProjectBDD/SpecFlowProjectBDD.csproj @@ -6,6 +6,18 @@ enable + + + + + + + + + + + + @@ -17,7 +29,7 @@ - + @@ -48,12 +60,6 @@ - - - Always - - - $(UsingMicrosoftNETSdk) diff --git a/Test/UITest/SpecFlowProjectBDD/StepDefinitions/AddSubsidiaryPlatform.cs b/Test/UITest/SpecFlowProjectBDD/StepDefinitions/AddSubsidiaryPlatform.cs new file mode 100644 index 00000000..8a22c835 --- /dev/null +++ b/Test/UITest/SpecFlowProjectBDD/StepDefinitions/AddSubsidiaryPlatform.cs @@ -0,0 +1,145 @@ +using Configuration; +using NUnit.Framework.Legacy; +using SpecFlowProjectBDD.Helpers; +using System; +using TechTalk.SpecFlow; +using TestFrameWork.Models; +using UITest.PageObjects; +using UITest.TestDriver; +using static SpecFlowProjectBDD.SFEnums; + +namespace SpecFlowProjectBDD.StepDefinitions +{ + [Binding] + public class AddSubsidiaryPlatform + { + private IDriver _Driver; + private LandingPage _LandingPage; + private DelistingWarningPage _DelistingWarningPage; + private PathFinderPage _PathFinderPage; + private IDirLoginPage _IDRLoginPage; + private NoticeOfTakeDownPage _NoticeOfTakeDownPage; + private string _TestUserName; + private string _TestPassword; + private bool _ExpectedResult = false; + private AppSettings _AppSettings; + private SFEnums.UserTypeEnum _UserType; + private BCIDPage _BCIDPage; + private SFEnums.LogonTypeEnum? _LogonType; + + public AddSubsidiaryPlatform(SeleniumDriver Driver) + { + _Driver = Driver; + _LandingPage = new LandingPage(_Driver); + _DelistingWarningPage = new DelistingWarningPage(_Driver); + + _PathFinderPage = new PathFinderPage(_Driver); + _IDRLoginPage = new IDirLoginPage(_Driver); + _BCIDPage = new BCIDPage(_Driver); + _AppSettings = new AppSettings(); + } + //User Authentication + [Given(@"that I am an authenticated User ""([^""]*)"" and the expected result is ""([^""]*)"" and I am a ""([^""]*)"" user")] + public void GivenThatIAmAnAuthenticatedUserAndTheExpectedResultIsAndIAmAUser(string UserName, string ExpectedResult, string UserType) + { + _TestUserName = UserName; + _TestPassword = _AppSettings.GetUser(_TestUserName) ?? string.Empty; + _ExpectedResult = ExpectedResult.ToUpper() == "PASS" ? true : false; + + _Driver.Url = _AppSettings.GetServer("default"); + _Driver.Navigate(); + + AuthHelper authHelper = new AuthHelper(_Driver); + UserHelper userHelper = new UserHelper(); + + _UserType = userHelper.SetUserType(UserType); + //Authenticate user using IDir or BCID depending on the user + _LogonType = authHelper.Authenticate(_TestUserName, _TestPassword, _UserType); + ClassicAssert.IsNotNull(_LogonType, "Logon FAILED"); + + TermsAndConditionsHelper termsAndConditionsHelper = new TermsAndConditionsHelper(_Driver); + termsAndConditionsHelper.HandleTermsAndConditions(); + } + + [Then(@"I am directed to the Landing Page")] + public void ThenIAmDirectedToTheLandingPage() + { + if (_UserType == UserTypeEnum.LOCALGOVERNMENT) + { + ClassicAssert.True(_LandingPage.ManagePlatformsButton.IsEnabled()); + } + } + + [When(@"I click on the Manage Platforms button")] + public void WhenIClickOnTheManagePlatformsButton() + { + _LandingPage.ManagePlatformsButton.Click(); + } + + [Then(@"I should be presented with a list of platforms and sub-platforms")] + public void ThenIShouldBePresentedWithAListOfPlatformsAndSub_Platforms() + { + + } + + [When(@"I click the edit button for a platform")] + public void WhenIClickTheEditButtonForAPlatform() + { + + } + + [Then(@"I amd directed to the Platform view page")] + public void ThenIAmdDirectedToThePlatformViewPage() + { + + } + + [When(@"I click on the add subsidiary platform button")] + public void WhenIClickOnTheAddSubsidiaryPlatformButton() + { + + } + + [Then(@"I should be presented with the Add Platform page")] + public void ThenIShouldBePresentedWithTheAddPlatformPage() + { + + } + + [Then(@"I should see a form with the required input fields for creating a sub-platform")] + public void ThenIShouldSeeAFormWithTheRequiredInputFieldsForCreatingASub_Platform() + { + + } + + [When(@"I fill in valid values for the input fields")] + public void WhenIFillInValidValuesForTheInputFields() + { + + } + + [Then(@"the Save button should be enabled")] + public void ThenTheSaveButtonShouldBeEnabled() + { + + } + + [When(@"I click the Save button")] + public void WhenIClickTheSaveButton() + { + + } + + [Then(@"the sub platform should be created")] + public void ThenTheSubPlatformShouldBeCreated() + { + + } + + [Then(@"the sub platform should be a child of the parent platform")] + public void ThenTheSubPlatformShouldBeAChildOfTheParentPlatform() + { + + } + } +} diff --git a/Test/UITest/TestFrameWork/Models/LandingPageModel.cs b/Test/UITest/TestFrameWork/Models/LandingPageModel.cs index 4ace24c7..fc3c4c35 100644 --- a/Test/UITest/TestFrameWork/Models/LandingPageModel.cs +++ b/Test/UITest/TestFrameWork/Models/LandingPageModel.cs @@ -17,5 +17,6 @@ public class LandingPageModel public static string ListingsButton { get => "listings_btn"; } public static string AggregatedListingsButton { get => "aggregated_listings_btn"; } + public static string ManagePlatformsButton { get => "platformManagement_btn"; } } } diff --git a/Test/UITest/TestFrameWork/PageObjects/LandingPage.cs b/Test/UITest/TestFrameWork/PageObjects/LandingPage.cs index 33cc5758..e749a276 100644 --- a/Test/UITest/TestFrameWork/PageObjects/LandingPage.cs +++ b/Test/UITest/TestFrameWork/PageObjects/LandingPage.cs @@ -16,6 +16,7 @@ public class LandingPage private Button _ViewPolicyGuidelinesButton; private Button _ViewListingsButton; private Button _AggregatedListingsButton; + private Button _ManagePlatformsButton; private IDriver _Driver; @@ -30,6 +31,8 @@ public class LandingPage public Button ViewPolicyGuidelinesButton { get => _ViewPolicyGuidelinesButton;} public Button ViewListingsButton { get => _ViewListingsButton; } public Button AggregatedListingsButton { get => _AggregatedListingsButton; } + public Button ManagePlatformsButton {get => _ManagePlatformsButton; } + public LandingPage(IDriver Driver) { @@ -43,6 +46,7 @@ public LandingPage(IDriver Driver) _ViewPolicyGuidelinesButton = new Button(Driver, Enums.FINDBY.ID, LandingPageModel.ViewPolicyGuidenceButton); _ViewListingsButton = new Button(Driver, Enums.FINDBY.ID, LandingPageModel.ListingsButton); _AggregatedListingsButton = new Button(Driver, Enums.FINDBY.ID, LandingPageModel.AggregatedListingsButton); + _ManagePlatformsButton = new Button(Driver, Enums.FINDBY.ID,LandingPageModel.ManagePlatformsButton); } public bool Navigate() diff --git a/Test/UITest/TestFrameWork/TestFrameWork.csproj b/Test/UITest/TestFrameWork/TestFrameWork.csproj index e640bacf..43f51b94 100644 --- a/Test/UITest/TestFrameWork/TestFrameWork.csproj +++ b/Test/UITest/TestFrameWork/TestFrameWork.csproj @@ -9,6 +9,7 @@ +