Skip to content

Commit

Permalink
Added framework for add subsidiary and fix bug where chrome driver wa…
Browse files Browse the repository at this point in the history
…s not deleted at end of test after error
  • Loading branch information
Rick Anderson authored and Rick Anderson committed Oct 26, 2024
1 parent ffcd514 commit cde00ea
Show file tree
Hide file tree
Showing 8 changed files with 402 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -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 "<UserName>" and the expected result is "<ExpectedResult>" and I am a "<UserType>" 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 |






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

45 changes: 30 additions & 15 deletions Test/UITest/SpecFlowProjectBDD/Hooks/SeleniumSpecFlowHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@

namespace SpecFlowProjectBDD.Hooks
{
/// <summary>
/// Hooks for scenario and test setup/teardown. Currently only uses Chrome and will need to be modified for other browser types
/// </summary>
[Binding]
public class SeleniumSpecFlowHooks
{
private int driverProcessPID;
private Process[] driverProcessess1;
private Process[] driverProcessess2;
private Process[] driverProcessess;
protected IObjectContainer _Container;

public SeleniumSpecFlowHooks(IObjectContainer container)
Expand All @@ -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);

Expand All @@ -42,7 +33,15 @@ public void SetupDrivers()
[AfterScenario(Order = 3)]
public void DestroyDrivers()
{
var webDriver = _Container.Resolve<SeleniumDriver>();
SeleniumDriver? webDriver = null;
try
{
webDriver = _Container.Resolve<SeleniumDriver>();
}
catch (BoDi.ObjectContainerException ex)
{
CleanupDrivers();
}

if (webDriver == null)
return;
Expand All @@ -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();
}
}
}


}
}
20 changes: 13 additions & 7 deletions Test/UITest/SpecFlowProjectBDD/SpecFlowProjectBDD.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

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

<ItemGroup>
<None Remove="chromedriver.exe" />
</ItemGroup>

<ItemGroup>
<SpecFlowObsoleteCodeBehindFiles Remove="Features\Calculator - Copy.feature.cs" />
<SpecFlowObsoleteCodeBehindFiles Remove="Features\SendingMultipleNoticesOfNonCompliance - Copy.feature.cs" />
Expand All @@ -17,7 +29,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Selenium.Support" Version="4.16.2" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="128.0.6613.8400" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="130.0.6723.6900" />
<PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.57" />
<PackageReference Include="SpecFlow.NUnit" Version="3.9.74" />
<PackageReference Include="nunit" Version="4.1.0" />
Expand Down Expand Up @@ -48,12 +60,6 @@
</Compile>
</ItemGroup>

<ItemGroup>
<None Update="chromedriver.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<SpecFlowFeatureFiles Update="Features\DenyAccessToSystem.feature">
<Visible>$(UsingMicrosoftNETSdk)</Visible>
Expand Down
Loading

0 comments on commit cde00ea

Please sign in to comment.