Skip to content

Commit

Permalink
Completed AddSubsidiaryPlatform test
Browse files Browse the repository at this point in the history
  • Loading branch information
Rick Anderson authored and Rick Anderson committed Oct 30, 2024
1 parent cde00ea commit 220168c
Show file tree
Hide file tree
Showing 11 changed files with 220 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: ManagePlatforms
Link to a feature: https://hous-hpb.atlassian.net/browse/DSS-226

@LandingPage
@AddSubsidiaryPlatform
Scenario: AddSubsidiaryPlatform
#User Authentication
Given that I am an authenticated User "<UserName>" and the expected result is "<ExpectedResult>" and I am a "<UserType>" user
Expand Down

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

10 changes: 10 additions & 0 deletions Test/UITest/SpecFlowProjectBDD/SpecFlowProjectBDD.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,20 @@

<ItemGroup>
<Compile Remove="chromedriver-win64 %282%29\**" />
<Compile Remove="NewFolder1\**" />
<Compile Remove="NewFolder\**" />
<EmbeddedResource Remove="chromedriver-win64 %282%29\**" />
<EmbeddedResource Remove="NewFolder1\**" />
<EmbeddedResource Remove="NewFolder\**" />
<None Remove="chromedriver-win64 %282%29\**" />
<None Remove="NewFolder1\**" />
<None Remove="NewFolder\**" />
<SpecFlowFeatureFiles Remove="chromedriver-win64 %282%29\**" />
<SpecFlowFeatureFiles Remove="NewFolder1\**" />
<SpecFlowFeatureFiles Remove="NewFolder\**" />
<SpecFlowObsoleteCodeBehindFiles Remove="chromedriver-win64 %282%29\**" />
<SpecFlowObsoleteCodeBehindFiles Remove="NewFolder1\**" />
<SpecFlowObsoleteCodeBehindFiles Remove="NewFolder\**" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Configuration;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities;
using NUnit.Framework.Legacy;
using SpecFlowProjectBDD.Helpers;
using System;
Expand All @@ -7,6 +8,7 @@
using UITest.PageObjects;
using UITest.TestDriver;
using static SpecFlowProjectBDD.SFEnums;
using SpecFlowProjectBDD.Utilities;

namespace SpecFlowProjectBDD.StepDefinitions
{
Expand All @@ -15,13 +17,24 @@ public class AddSubsidiaryPlatform
{
private IDriver _Driver;
private LandingPage _LandingPage;
private DelistingWarningPage _DelistingWarningPage;
private ManagePlatformsPage _ManagePlatformsPage;
private DetailedPlatformContactInformationPage _DetailedPlatformContactInformationPage;
private AddNewPlatformPage _AddNewPlatformPage;
private PathFinderPage _PathFinderPage;
private IDirLoginPage _IDRLoginPage;
private NoticeOfTakeDownPage _NoticeOfTakeDownPage;

private string _TestUserName;
private string _TestPassword;
private bool _ExpectedResult = false;
private bool _ExpectedResult = false;
private string _PlatformName = string.Empty ;
private string _PlatformCode = string.Empty;
private string _EmailForNonComplianceNotices = string.Empty;
private string _EmailForTakedownRequestLetters = string.Empty;
private string _SecondaryEmailForNonComplianceNotices = string.Empty;
private string _SecondaryEmailForTakedownRequest = string.Empty;

private StrUtilities _strUtilities;

private AppSettings _AppSettings;
private SFEnums.UserTypeEnum _UserType;
private BCIDPage _BCIDPage;
Expand All @@ -31,12 +44,20 @@ public AddSubsidiaryPlatform(SeleniumDriver Driver)
{
_Driver = Driver;
_LandingPage = new LandingPage(_Driver);
_DelistingWarningPage = new DelistingWarningPage(_Driver);

_ManagePlatformsPage = new ManagePlatformsPage(_Driver);
_DetailedPlatformContactInformationPage = new DetailedPlatformContactInformationPage(_Driver);
_AddNewPlatformPage = new AddNewPlatformPage(_Driver);
_PathFinderPage = new PathFinderPage(_Driver);
_IDRLoginPage = new IDirLoginPage(_Driver);
_BCIDPage = new BCIDPage(_Driver);
_AppSettings = new AppSettings();
_strUtilities = new StrUtilities();
_PlatformName = "Sub-PlatForm" + _strUtilities.GenerateRandomString(50);
_PlatformCode = "PC" + _strUtilities.GenerateRandomString(13);
_EmailForNonComplianceNotices = "Foo@foo.com";
_EmailForTakedownRequestLetters = "Foo@foo.com";
_SecondaryEmailForNonComplianceNotices = "Foo@foo.com";
_SecondaryEmailForTakedownRequest = "Foo@foo.com";
}
//User Authentication
[Given(@"that I am an authenticated User ""([^""]*)"" and the expected result is ""([^""]*)"" and I am a ""([^""]*)"" user")]
Expand Down Expand Up @@ -73,31 +94,34 @@ public void ThenIAmDirectedToTheLandingPage()
[When(@"I click on the Manage Platforms button")]
public void WhenIClickOnTheManagePlatformsButton()
{
Thread.Sleep(3000);
_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()
{

_ManagePlatformsPage.EditPlatformButton.Click();
}

[Then(@"I amd directed to the Platform view page")]
public void ThenIAmdDirectedToThePlatformViewPage()
{


}

[When(@"I click on the add subsidiary platform button")]
public void WhenIClickOnTheAddSubsidiaryPlatformButton()
{

_DetailedPlatformContactInformationPage.AddSubsidiaryPlatformButton.Click();
}

[Then(@"I should be presented with the Add Platform page")]
Expand All @@ -115,19 +139,24 @@ public void ThenIShouldSeeAFormWithTheRequiredInputFieldsForCreatingASub_Platfor
[When(@"I fill in valid values for the input fields")]
public void WhenIFillInValidValuesForTheInputFields()
{

_AddNewPlatformPage.PlatformNameTextBox.EnterText(_PlatformName);
_AddNewPlatformPage.PlatformCodeTextBox.EnterText(_PlatformCode);
_AddNewPlatformPage.EmailForNonComplianceNoticesTextBox.EnterText(_EmailForNonComplianceNotices);
_AddNewPlatformPage.EmailForTakedownRequestLettersTextBox.EnterText(_EmailForTakedownRequestLetters);
_AddNewPlatformPage.SecondaryEmailForNonComplianceNoticesTextBox.EnterText(_SecondaryEmailForNonComplianceNotices);
_AddNewPlatformPage.SecondaryEmailForTakedownRequest.EnterText(_SecondaryEmailForTakedownRequest);
}

[Then(@"the Save button should be enabled")]
public void ThenTheSaveButtonShouldBeEnabled()
{

ClassicAssert.IsTrue(_AddNewPlatformPage.SaveButton.IsEnabled());
}

[When(@"I click the Save button")]
public void WhenIClickTheSaveButton()
{

_AddNewPlatformPage.SaveButton.Click();
}

[Then(@"the sub platform should be created")]
Expand Down
13 changes: 13 additions & 0 deletions Test/UITest/SpecFlowProjectBDD/Utilities/StringUtilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace SpecFlowProjectBDD.Utilities;
public class StrUtilities
{
public string GenerateRandomString(int length)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var random = new Random();
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)])
.ToArray());
}

}
19 changes: 19 additions & 0 deletions Test/UITest/TestFrameWork/Models/AddNewPlatformPageModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using OpenQA.Selenium;

namespace UITest.Models
{
public class AddNewPlatformPageModel
{


public static string PlatformNameTextBox { get => "organizationNm"; }
public static string PlatformCodeTextBox { get => "organizationCd"; }
public static string EmailForNonComplianceNoticesTextBox { get => "primaryNoticeOfTakedownContactEmail"; }
public static string EmailForTakedownRequestLettersTextBox { get => "primaryTakedownRequestContactEmail"; }
public static string SecondaryEmailForNonComplianceNoticesTextBox {get => "secondaryNoticeOfTakedownContactEmail"; }
public static string SecondaryEmailForTakedownRequest { get => "secondaryTakedownRequestContactEmail"; }
public static string SaveButton { get => "body > app-root > app-layout > div.content > app-add-sub-platform > div.actions.ng-star-inserted > button:nth-child(1)"; }
public static string CancelButton { get => "body > app-root > app-layout > div.content > app-add-sub-platform > div.actions.ng-star-inserted > button.p-element.p-button-transparent.p-button.p-component"; }

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace UITest.Models
{
public class DetailedPlatformContactInformationPageModel
{
public static string AddSubsidiaryPlatformButton { get => "body > app-root > app-layout > div.content > app-view-platform > div.header > button"; }
}
}
11 changes: 11 additions & 0 deletions Test/UITest/TestFrameWork/Models/ManagePlatformsPageModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace UITest.Models
{
public class ManagePlatformsPageModel
{

public static string EditPlatformButton { get => "#platform-edit-0-icon"; }

public static string ListingsTable { get => "listings-table"; }

}
}
51 changes: 51 additions & 0 deletions Test/UITest/TestFrameWork/PageObjects/AddNewPlatformPage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using UITest.Models;
using UITest.SeleniumObjects;
using UITest.TestDriver;
using UITest.TestObjectFramework;

namespace UITest.PageObjects
{
public class AddNewPlatformPage
{
private IDriver _Driver;

//No Valid URL since the URL must contain a unique and new platform number
//private string _URL = @"http://127.0.0.1:4200/add-sub-platform/590";

private TextBox _PlatformNameTextBox;

private TextBox _PlatformCodeTextBox;

private TextBox _EmailForNonComplianceNoticesTextBox;
private TextBox _EmailForTakedownRequestLettersTextBox;
private TextBox _SecondaryEmailForNonComplianceNoticesTextBox;
private TextBox _SecondaryEmailForTakedownRequest;
private Button _CancelButton;
private Button _SaveButton;

public TextBox PlatformNameTextBox { get => _PlatformNameTextBox; }
public TextBox PlatformCodeTextBox { get => _PlatformCodeTextBox; }
public TextBox EmailForNonComplianceNoticesTextBox { get => _EmailForNonComplianceNoticesTextBox; }
public TextBox EmailForTakedownRequestLettersTextBox { get => _EmailForTakedownRequestLettersTextBox; }
public TextBox SecondaryEmailForNonComplianceNoticesTextBox { get => _SecondaryEmailForNonComplianceNoticesTextBox; }
public TextBox SecondaryEmailForTakedownRequest { get => _SecondaryEmailForTakedownRequest; }
public Button SaveButton { get => _SaveButton; }
public Button CancelButton { get => _CancelButton; }
//public string URL { get => _URL; set => _URL = value; }
public IDriver Driver { get => _Driver; }

public AddNewPlatformPage(IDriver Driver)
{
_Driver = Driver;

_PlatformNameTextBox = new TextBox(Driver, Enums.FINDBY.ID, AddNewPlatformPageModel.PlatformNameTextBox);
_PlatformCodeTextBox = new TextBox(Driver, Enums.FINDBY.ID, AddNewPlatformPageModel.PlatformCodeTextBox);
_EmailForNonComplianceNoticesTextBox = new TextBox(Driver, Enums.FINDBY.ID, AddNewPlatformPageModel.EmailForNonComplianceNoticesTextBox);
_EmailForTakedownRequestLettersTextBox = new TextBox(Driver, Enums.FINDBY.ID, AddNewPlatformPageModel.EmailForTakedownRequestLettersTextBox);
_SecondaryEmailForNonComplianceNoticesTextBox = new TextBox(Driver, Enums.FINDBY.ID, AddNewPlatformPageModel.SecondaryEmailForNonComplianceNoticesTextBox);
_SecondaryEmailForTakedownRequest = new TextBox(Driver, Enums.FINDBY.ID, AddNewPlatformPageModel.SecondaryEmailForTakedownRequest);
_SaveButton = new Button(Driver, Enums.FINDBY.CSSSELECTOR, AddNewPlatformPageModel.SaveButton);
_CancelButton = new Button(Driver, Enums.FINDBY.CSSSELECTOR, AddNewPlatformPageModel.CancelButton);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using UITest.Models;
using UITest.SeleniumObjects;
using UITest.TestDriver;
using UITest.TestObjectFramework;

namespace UITest.PageObjects
{
public class DetailedPlatformContactInformationPage
{
private IDriver _Driver;

private string _URL = @"http://127.0.0.1:4200/platform/590";

private Button _AddSubsidiaryPlatformButton;


public string URL { get => _URL; set => _URL = value; }

public Button AddSubsidiaryPlatformButton { get => _AddSubsidiaryPlatformButton; set => _AddSubsidiaryPlatformButton = value; }


public IDriver Driver { get => _Driver; }

public DetailedPlatformContactInformationPage(IDriver Driver)
{
_Driver = Driver;

_AddSubsidiaryPlatformButton = new Button(Driver, Enums.FINDBY.CSSSELECTOR, DetailedPlatformContactInformationPageModel.AddSubsidiaryPlatformButton);

}
}
}
35 changes: 35 additions & 0 deletions Test/UITest/TestFrameWork/PageObjects/ManagePlatformsPage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using UITest.Models;
using UITest.SeleniumObjects;
using UITest.TestDriver;
using UITest.TestObjectFramework;

namespace UITest.PageObjects
{
public class ManagePlatformsPage
{
private IDriver _Driver;

private string _URL = @"http://127.0.0.1:4200/platform-management";

private Button _EditPlatformButton;

private Table _ListingsTable;

public string URL { get => _URL; set => _URL = value; }


public Button EditPlatformButton { get => _EditPlatformButton; set => _EditPlatformButton = value; }

public Table ListingsTable { get => _ListingsTable; }
public IDriver Driver { get => _Driver; }

public ManagePlatformsPage(IDriver Driver)
{
_Driver = Driver;

_EditPlatformButton = new Button(Driver, Enums.FINDBY.CSSSELECTOR, ManagePlatformsPageModel.EditPlatformButton);

_ListingsTable = new Table(Driver, Enums.FINDBY.ID, ManagePlatformsPageModel.ListingsTable);
}
}
}

0 comments on commit 220168c

Please sign in to comment.