Removing legacy test automation
This commit is contained in:
@@ -11,8 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Components", "..\Components
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Services", "..\Services\Services.csproj", "{621178C8-4E8B-478E-80E5-7478F0E7B67E}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Services", "..\Services\Services.csproj", "{621178C8-4E8B-478E-80E5-7478F0E7B67E}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestAutomation", "..\TestAutomation\TestAutomation.csproj", "{8B49D038-D013-460D-9C4F-817CAFFEB06F}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -35,10 +33,6 @@ Global
|
|||||||
{621178C8-4E8B-478E-80E5-7478F0E7B67E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{621178C8-4E8B-478E-80E5-7478F0E7B67E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{621178C8-4E8B-478E-80E5-7478F0E7B67E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{621178C8-4E8B-478E-80E5-7478F0E7B67E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{621178C8-4E8B-478E-80E5-7478F0E7B67E}.Release|Any CPU.Build.0 = Release|Any CPU
|
{621178C8-4E8B-478E-80E5-7478F0E7B67E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{8B49D038-D013-460D-9C4F-817CAFFEB06F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{8B49D038-D013-460D-9C4F-817CAFFEB06F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{8B49D038-D013-460D-9C4F-817CAFFEB06F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{8B49D038-D013-460D-9C4F-817CAFFEB06F}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
using TestAutomation.Utils;
|
|
||||||
|
|
||||||
namespace TestAutomation;
|
|
||||||
|
|
||||||
public enum DeploymentType
|
|
||||||
{
|
|
||||||
Dev,
|
|
||||||
Local
|
|
||||||
}
|
|
||||||
|
|
||||||
public class BaseTest
|
|
||||||
{
|
|
||||||
protected static readonly TestReport TestReport = new();
|
|
||||||
|
|
||||||
|
|
||||||
protected static Website WebsiteInstance = default!;
|
|
||||||
protected readonly HttpClient HttpClient = new();
|
|
||||||
|
|
||||||
protected static Website Website
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (WebsiteInstance == null)
|
|
||||||
{
|
|
||||||
var options = new FirefoxOptions();
|
|
||||||
|
|
||||||
options.AcceptInsecureCertificates = true;
|
|
||||||
|
|
||||||
if (Website.DeploymentType.Equals(DeploymentType.Dev)) options.AddArgument("--headless");
|
|
||||||
options.AddArgument("--ignore-certificate-errors");
|
|
||||||
options.AddArgument("--start-maximized");
|
|
||||||
options.AddArgument("--test-type");
|
|
||||||
options.AddArgument("--allow-running-insecure-content");
|
|
||||||
|
|
||||||
IWebDriver webDriver = new FirefoxDriver(Environment.CurrentDirectory, options);
|
|
||||||
|
|
||||||
WebsiteInstance = new Website(webDriver, TestReport);
|
|
||||||
}
|
|
||||||
|
|
||||||
return WebsiteInstance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
namespace TestAutomation.Enums;
|
|
||||||
|
|
||||||
public enum ScreenType
|
|
||||||
{
|
|
||||||
Desktop,
|
|
||||||
Tablet,
|
|
||||||
Mobile
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
using TestAutomation.Shared;
|
|
||||||
using TestAutomation.Utils;
|
|
||||||
|
|
||||||
namespace TestAutomation.Pages;
|
|
||||||
|
|
||||||
public abstract class BasePage : BaseElement
|
|
||||||
{
|
|
||||||
protected BasePage(Website website) : base(website)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerable<string> Links =>
|
|
||||||
Website.FindAllWithTag(Website.Find("content"), "a")
|
|
||||||
.Select(x => x.GetAttribute("href"));
|
|
||||||
|
|
||||||
public abstract string Url { get; set; }
|
|
||||||
|
|
||||||
public IEnumerable<string> GetLinks()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return Links;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new Exception($"Couldn't get links on page {Url}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
using System.Collections.ObjectModel;
|
|
||||||
using TestAutomation.Utils;
|
|
||||||
|
|
||||||
namespace TestAutomation.Pages;
|
|
||||||
|
|
||||||
public class DatabasePage : BasePage
|
|
||||||
{
|
|
||||||
public DatabasePage(Website website) : base(website)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private IWebElement FilterNameInput => Website.Find("filterName");
|
|
||||||
|
|
||||||
public override string Url { get; set; } = "database";
|
|
||||||
|
|
||||||
|
|
||||||
private ReadOnlyCollection<IWebElement> EntityNames()
|
|
||||||
{
|
|
||||||
return Website.FindAll("entityName");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private IWebElement EntityName(string entityType, string entityName)
|
|
||||||
{
|
|
||||||
return Website.Find("entityName",
|
|
||||||
$"{entityType.ToLower()}-{entityName.ToLower()}");
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatabasePage FilterName(string name)
|
|
||||||
{
|
|
||||||
Website.EnterInput(FilterNameInput, name);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatabasePage GetEntityName(string entityType, string entityName, out string result)
|
|
||||||
{
|
|
||||||
result = EntityName(entityType, entityName).Text;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatabasePage GetEntityName(int index, out string result)
|
|
||||||
{
|
|
||||||
result = EntityNames()[index].Text;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatabasePage Goto()
|
|
||||||
{
|
|
||||||
Website.Goto(Url);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
using TestAutomation.Utils;
|
|
||||||
|
|
||||||
namespace TestAutomation.Pages;
|
|
||||||
|
|
||||||
public class DatabaseSinglePage : BasePage
|
|
||||||
{
|
|
||||||
public DatabaseSinglePage(Website website) : base(website)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private IWebElement EntityName => Website.Find("entityName");
|
|
||||||
private IWebElement EntityHealth => Website.Find("entityHealth");
|
|
||||||
|
|
||||||
private IWebElement InvalidSearch => Website.Find("invalidSearch");
|
|
||||||
private IWebElement ValidSearch => Website.Find("validSearch");
|
|
||||||
|
|
||||||
public override string Url { get; set; } = "database";
|
|
||||||
|
|
||||||
|
|
||||||
public DatabaseSinglePage GetEntityName(out string result)
|
|
||||||
{
|
|
||||||
result = EntityName.Text;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatabaseSinglePage GetEntityHealth(out string result)
|
|
||||||
{
|
|
||||||
result = EntityHealth.Text;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatabaseSinglePage GetInvalidSearch(out string result)
|
|
||||||
{
|
|
||||||
result = InvalidSearch.Text;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatabaseSinglePage GetValidSearch(out string result)
|
|
||||||
{
|
|
||||||
result = ValidSearch.Text;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatabaseSinglePage Goto(string searchText)
|
|
||||||
{
|
|
||||||
Website.Goto($"{Url}/{searchText}");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
using TestAutomation.Utils;
|
|
||||||
|
|
||||||
namespace TestAutomation.Pages;
|
|
||||||
|
|
||||||
public class HarassCalculatorPage : BasePage
|
|
||||||
{
|
|
||||||
public HarassCalculatorPage(Website website) : base(website)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private IWebElement NumberOfWorkersLostToHarass => Website.Find("numberOfWorkersLostToHarass");
|
|
||||||
private IWebElement NumberOfTownHallsExisting => Website.Find("numberOfTownHallsExisting");
|
|
||||||
private IList<IWebElement> OnTownHallTravelTimes => Website.FindChildren("numberOfTownHallTravelTimes", "input");
|
|
||||||
private int TotalAlloyHarassment => Website.FindInt("totalAlloyHarassment");
|
|
||||||
private int WorkerReplacementCost => Website.FindInt("workerReplacementCost");
|
|
||||||
private int DelayedMiningCost => Website.FindInt("delayedMiningCost");
|
|
||||||
private int AverageTravelTime => Website.FindInt("getAverageTravelTime");
|
|
||||||
|
|
||||||
private int ExampleTotalAlloyLoss => Website.FindInt("exampleTotalAlloyLoss");
|
|
||||||
private int ExampleWorkerCost => Website.FindInt("exampleWorkerCost");
|
|
||||||
private int ExampleMiningTimeCost => Website.FindInt("exampleMiningTimeCost");
|
|
||||||
private int ExampleTotalAlloyLossDifference => Website.FindInt("exampleTotalAlloyLossDifference");
|
|
||||||
private int ExampleTotalAlloyLossAccurate => Website.FindInt("exampleTotalAlloyLossAccurate");
|
|
||||||
private int ExampleTotalAlloyLossAccurateDifference => Website.FindInt("exampleTotalAlloyLossAccurateDifference");
|
|
||||||
|
|
||||||
public override string Url { get; set; } = "harass-calculator";
|
|
||||||
|
|
||||||
public HarassCalculatorPage SetWorkersLostToHarass(int number)
|
|
||||||
{
|
|
||||||
Website.EnterInput(NumberOfWorkersLostToHarass, number);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HarassCalculatorPage SetNumberOfTownHallsExisting(int number)
|
|
||||||
{
|
|
||||||
Website.EnterInput(NumberOfTownHallsExisting, number);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HarassCalculatorPage SetTownHallTravelTime(int forTownHall, int number)
|
|
||||||
{
|
|
||||||
Website.EnterInput(OnTownHallTravelTimes[forTownHall], number);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HarassCalculatorPage GetTotalAlloyHarassment(out int result)
|
|
||||||
{
|
|
||||||
result = TotalAlloyHarassment;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public HarassCalculatorPage GetExampleTotalAlloyLoss(out int result)
|
|
||||||
{
|
|
||||||
result = ExampleTotalAlloyLoss;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HarassCalculatorPage GetExampleWorkerCost(out int result)
|
|
||||||
{
|
|
||||||
result = ExampleWorkerCost;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HarassCalculatorPage GetExampleMiningTimeCost(out int result)
|
|
||||||
{
|
|
||||||
result = ExampleMiningTimeCost;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HarassCalculatorPage GetExampleTotalAlloyLossAccurate(out int result)
|
|
||||||
{
|
|
||||||
result = ExampleTotalAlloyLossAccurate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HarassCalculatorPage GetExampleTotalAlloyLossDifference(out int result)
|
|
||||||
{
|
|
||||||
result = ExampleTotalAlloyLossDifference;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HarassCalculatorPage GetExampleTotalAlloyLossAccurateDifference(out int result)
|
|
||||||
{
|
|
||||||
result = ExampleTotalAlloyLossAccurateDifference;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected HarassCalculatorPage NavigateTo()
|
|
||||||
{
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HarassCalculatorPage Goto()
|
|
||||||
{
|
|
||||||
Website.Goto(Url);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
using TestAutomation.Utils;
|
|
||||||
|
|
||||||
namespace TestAutomation.Shared;
|
|
||||||
|
|
||||||
public abstract class BaseElement
|
|
||||||
{
|
|
||||||
protected readonly Website Website;
|
|
||||||
|
|
||||||
protected BaseElement(Website website)
|
|
||||||
{
|
|
||||||
Website = website;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
using TestAutomation.Utils;
|
|
||||||
|
|
||||||
namespace TestAutomation.Shared;
|
|
||||||
|
|
||||||
public class NavigationBar : BaseElement
|
|
||||||
{
|
|
||||||
public NavigationBar(Website website) : base(website)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private IWebElement HomeLink => Website.FindScreenSpecific("homeLink");
|
|
||||||
private IWebElement SearchButton => Website.FindScreenSpecific("searchButton");
|
|
||||||
|
|
||||||
public NavigationBar ClickHomeLink()
|
|
||||||
{
|
|
||||||
Website.Click(HomeLink);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WebsiteSearchDialog ClickSearchButton()
|
|
||||||
{
|
|
||||||
Website.Click(SearchButton);
|
|
||||||
return Website.WebsiteSearchDialog;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
using TestAutomation.Utils;
|
|
||||||
|
|
||||||
namespace TestAutomation.Shared;
|
|
||||||
|
|
||||||
public class WebsiteSearchDialog : BaseElement
|
|
||||||
{
|
|
||||||
public WebsiteSearchDialog(Website website) : base(website)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public IWebElement SearchBackground => Website.Find("searchBackground");
|
|
||||||
|
|
||||||
public IWebElement SearchInput => Website.Find("searchInput");
|
|
||||||
|
|
||||||
public NavigationBar CloseDialog()
|
|
||||||
{
|
|
||||||
Website.ClickTopLeft();
|
|
||||||
return Website.NavigationBar;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WebsiteSearchDialog Search(string throne)
|
|
||||||
{
|
|
||||||
Website.EnterInput(SearchInput, throne);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatabaseSinglePage SelectSearchEntity(string throne)
|
|
||||||
{
|
|
||||||
Website.Click(Website.FindButtonWithLabel(throne));
|
|
||||||
return Website.DatabaseSinglePage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Discord.Net.Webhook" Version="3.6.0"/>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.14"/>
|
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0"/>
|
|
||||||
<PackageReference Include="NUnit" Version="3.13.2"/>
|
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="4.2.0"/>
|
|
||||||
<PackageReference Include="NUnit.Analyzers" Version="3.2.0"/>
|
|
||||||
<PackageReference Include="coverlet.collector" Version="3.1.0"/>
|
|
||||||
<PackageReference Include="Selenium.WebDriver" Version="4.1.0"/>
|
|
||||||
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="101.0.4951.4100"/>
|
|
||||||
<PackageReference Include="Selenium.WebDriver.GeckoDriver" Version="0.31.0"/>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Pages\"/>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
using TestAutomation.Utils;
|
|
||||||
|
|
||||||
namespace TestAutomation;
|
|
||||||
|
|
||||||
[TestFixture]
|
|
||||||
public class TestHarassCalculator : BaseTest
|
|
||||||
{
|
|
||||||
[SetUp]
|
|
||||||
public void SetUp()
|
|
||||||
{
|
|
||||||
TestReport.CreateTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
[TearDown]
|
|
||||||
public void TearDown()
|
|
||||||
{
|
|
||||||
TestReport.ThrowErrors();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void CalculatorInput()
|
|
||||||
{
|
|
||||||
var expectedTotalAlloyHarassment = 240;
|
|
||||||
|
|
||||||
Website.HarassCalculatorPage
|
|
||||||
.Goto()
|
|
||||||
.SetWorkersLostToHarass(3)
|
|
||||||
.SetNumberOfTownHallsExisting(2)
|
|
||||||
.SetTownHallTravelTime(0, 30)
|
|
||||||
.GetTotalAlloyHarassment(out var foundTotalAlloyHarassment);
|
|
||||||
|
|
||||||
TestReport.CheckPassed(expectedTotalAlloyHarassment.Equals(foundTotalAlloyHarassment),
|
|
||||||
TestMessage.CreateFailedMessage($"expectTotalAlloyHarassment of {expectedTotalAlloyHarassment} " +
|
|
||||||
"does not equal " +
|
|
||||||
$"foundTotalAlloyHarassment of {foundTotalAlloyHarassment} "));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void CalculatedExampleInformation()
|
|
||||||
{
|
|
||||||
var expectedExampleTotalAlloyLoss = 720;
|
|
||||||
var expectedExampleWorkerCost = 300;
|
|
||||||
var expectedExampleMiningTimeCost = 420;
|
|
||||||
var expectedExampleTotalAlloyLossDifference = 300;
|
|
||||||
var expectedExampleTotalAlloyLossAccurate = 450;
|
|
||||||
var expectedExampleTotalAlloyLossAccurateDifference = 270;
|
|
||||||
|
|
||||||
Website.HarassCalculatorPage
|
|
||||||
.Goto()
|
|
||||||
.GetExampleTotalAlloyLoss(out var foundTotalAlloyLoss)
|
|
||||||
.GetExampleWorkerCost(out var foundExampleWorkerCost)
|
|
||||||
.GetExampleMiningTimeCost(out var foundExampleMiningTimeCost)
|
|
||||||
.GetExampleTotalAlloyLossAccurate(out var foundExampleTotalAlloyLossAccurate)
|
|
||||||
.GetExampleTotalAlloyLossDifference(out var foundGetExampleTotalAlloyLossDifference)
|
|
||||||
.GetExampleTotalAlloyLossAccurateDifference(out var foundExampleTotalAlloyLossAccurateDifference);
|
|
||||||
|
|
||||||
TestReport.CheckPassed(expectedExampleTotalAlloyLoss.Equals(foundTotalAlloyLoss),
|
|
||||||
TestMessage.CreateFailedMessage($"expectedExampleTotalAlloyLoss of {expectedExampleTotalAlloyLoss} " +
|
|
||||||
"does not equal " +
|
|
||||||
$"foundTotalAlloyLoss of {foundTotalAlloyLoss} "));
|
|
||||||
|
|
||||||
TestReport.CheckPassed(expectedExampleWorkerCost.Equals(foundExampleWorkerCost),
|
|
||||||
TestMessage.CreateFailedMessage($"expectedExampleWorkerCost of {expectedExampleWorkerCost} " +
|
|
||||||
"does not equal " +
|
|
||||||
$"foundExampleWorkerCost of {foundExampleWorkerCost} "));
|
|
||||||
|
|
||||||
|
|
||||||
TestReport.CheckPassed(expectedExampleMiningTimeCost.Equals(foundExampleMiningTimeCost),
|
|
||||||
TestMessage.CreateFailedMessage($"expectedExampleMiningTimeCost of {expectedExampleMiningTimeCost} " +
|
|
||||||
"does not equal " +
|
|
||||||
$"foundExampleMiningTimeCost of {foundExampleMiningTimeCost} "));
|
|
||||||
|
|
||||||
|
|
||||||
TestReport.CheckPassed(expectedExampleTotalAlloyLossAccurate.Equals(foundExampleTotalAlloyLossAccurate),
|
|
||||||
TestMessage.CreateFailedMessage(
|
|
||||||
$"expectedExampleTotalAlloyLossAccurate of {expectedExampleTotalAlloyLossAccurate} " +
|
|
||||||
"does not equal " +
|
|
||||||
$"foundExampleTotalAlloyLossAccurate of {foundExampleTotalAlloyLossAccurate} "));
|
|
||||||
|
|
||||||
|
|
||||||
TestReport.CheckPassed(expectedExampleTotalAlloyLossDifference.Equals(foundGetExampleTotalAlloyLossDifference),
|
|
||||||
TestMessage.CreateFailedMessage(
|
|
||||||
$"expectedExampleTotalAlloyLossDifference of {expectedExampleTotalAlloyLossDifference} " +
|
|
||||||
"does not equal " +
|
|
||||||
$"foundGetExampleTotalAlloyLossDifference of {foundGetExampleTotalAlloyLossDifference} "));
|
|
||||||
|
|
||||||
|
|
||||||
TestReport.CheckPassed(
|
|
||||||
expectedExampleTotalAlloyLossAccurateDifference.Equals(foundExampleTotalAlloyLossAccurateDifference),
|
|
||||||
TestMessage.CreateFailedMessage(
|
|
||||||
$"expectedExampleTotalAlloyLossAccurateDifference of {expectedExampleTotalAlloyLossAccurateDifference} " +
|
|
||||||
"does not equal " +
|
|
||||||
$"foundExampleTotalAlloyLossAccurateDifference of {foundExampleTotalAlloyLossAccurateDifference} "));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
namespace TestAutomation;
|
|
||||||
|
|
||||||
[TestFixture]
|
|
||||||
public class TestLinks : BaseTest
|
|
||||||
{
|
|
||||||
[SetUp]
|
|
||||||
public void SetUp()
|
|
||||||
{
|
|
||||||
TestReport.CreateTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
[TearDown]
|
|
||||||
public void TearDown()
|
|
||||||
{
|
|
||||||
TestReport.ThrowErrors();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void VerifyPageLinks()
|
|
||||||
{
|
|
||||||
Website.HarassCalculatorPage.Goto();
|
|
||||||
TestReport.VerifyLinks(Website.HarassCalculatorPage).Wait();
|
|
||||||
|
|
||||||
Website.DatabasePage.Goto();
|
|
||||||
TestReport.VerifyLinks(Website.DatabasePage).Wait();
|
|
||||||
|
|
||||||
Website.DatabaseSinglePage.Goto("throne");
|
|
||||||
TestReport.VerifyLinks(Website.DatabaseSinglePage).Wait();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
using TestAutomation.Utils;
|
|
||||||
|
|
||||||
namespace TestAutomation;
|
|
||||||
|
|
||||||
[TestFixture]
|
|
||||||
public class TestSearchFeatures : BaseTest
|
|
||||||
{
|
|
||||||
[SetUp]
|
|
||||||
public void SetUp()
|
|
||||||
{
|
|
||||||
TestReport.CreateTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
[TearDown]
|
|
||||||
public void TearDown()
|
|
||||||
{
|
|
||||||
TestReport.ThrowErrors();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void DesktopOpenCloseSearchDialog()
|
|
||||||
{
|
|
||||||
Website
|
|
||||||
.Goto()
|
|
||||||
.NavigationBar
|
|
||||||
.ClickSearchButton()
|
|
||||||
.CloseDialog()
|
|
||||||
.ClickHomeLink();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void DesktopSearchForThrone()
|
|
||||||
{
|
|
||||||
Website
|
|
||||||
.Goto()
|
|
||||||
.NavigationBar.ClickSearchButton()
|
|
||||||
.Search("Throne")
|
|
||||||
.SelectSearchEntity("Throne")
|
|
||||||
.GetEntityName(out var name)
|
|
||||||
.GetEntityHealth(out var health);
|
|
||||||
|
|
||||||
TestReport.CheckPassed(name.Equals("Throne"),
|
|
||||||
new TestMessage { Description = "Couldn't find Throne via search." });
|
|
||||||
TestReport.CheckPassed(!health.Trim().Equals(""),
|
|
||||||
new TestMessage { Description = "Throne has no visible health!" });
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void DesktopFilterForThrone()
|
|
||||||
{
|
|
||||||
Website.DatabasePage
|
|
||||||
.Goto()
|
|
||||||
.FilterName("Throne")
|
|
||||||
.GetEntityName(0, out var name);
|
|
||||||
|
|
||||||
TestReport.CheckPassed(name.Equals("Throne"),
|
|
||||||
new TestMessage { Description = "Couldn't find Throne via filter." });
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void SeeThroneByDefault()
|
|
||||||
{
|
|
||||||
Website.DatabasePage
|
|
||||||
.Goto()
|
|
||||||
.GetEntityName("army", "throne", out var name);
|
|
||||||
|
|
||||||
TestReport.CheckPassed(name.Equals("Throne"),
|
|
||||||
new TestMessage { Description = "Couldn't find Throne on the page by default." });
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void DirectLinkNotThroneFailure()
|
|
||||||
{
|
|
||||||
Website.DatabaseSinglePage
|
|
||||||
.Goto("not throne")
|
|
||||||
.GetInvalidSearch(out var invalidSearch)
|
|
||||||
.GetValidSearch(out var validSearch);
|
|
||||||
|
|
||||||
TestReport.CheckPassed(invalidSearch.Equals("not throne"),
|
|
||||||
new TestMessage { Description = "Couldn't find invalid search text on the page." });
|
|
||||||
TestReport.CheckPassed(validSearch.Equals("Throne"),
|
|
||||||
new TestMessage { Description = "Couldn't find valid search text on the page." });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
namespace TestAutomation.Utils;
|
|
||||||
|
|
||||||
public class Test
|
|
||||||
{
|
|
||||||
public string Name { get; set; } = "Name...";
|
|
||||||
public bool Result { get; set; } = true;
|
|
||||||
public IList<TestMessage> Messages { get; set; } = new List<TestMessage>();
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
namespace TestAutomation.Utils;
|
|
||||||
|
|
||||||
public class TestMessage
|
|
||||||
{
|
|
||||||
public string Title { get; set; } = "Name...";
|
|
||||||
public string Description { get; set; } = "";
|
|
||||||
public string Color { get; set; } = "FFFFFF";
|
|
||||||
|
|
||||||
public static TestMessage CreateFailedMessage(string description)
|
|
||||||
{
|
|
||||||
return new TestMessage { Title = "Check Failed", Description = description, Color = "FF0000" };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
using System.Globalization;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
|
|
||||||
namespace TestAutomation.Utils;
|
|
||||||
|
|
||||||
public class TestReport
|
|
||||||
{
|
|
||||||
private List<Test> Tests { get; } = new();
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
|
||||||
public Test CreateTest()
|
|
||||||
{
|
|
||||||
Tests.Add(new Test
|
|
||||||
{
|
|
||||||
Name = TestContext.CurrentContext.Test.Name
|
|
||||||
});
|
|
||||||
return Tests.Last();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ThrowErrors()
|
|
||||||
{
|
|
||||||
if (!Tests.Last().Result)
|
|
||||||
{
|
|
||||||
var messages = string.Join("\n", Tests.Last().Messages.Select(x => x.Description).ToList());
|
|
||||||
|
|
||||||
throw new Exception(
|
|
||||||
$"{Tests.Last().Name} test failed with {Tests.Last().Messages.Count} messages.\n\n{messages}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task VerifyLinks(BasePage page)
|
|
||||||
{
|
|
||||||
foreach (var link in page.GetLinks())
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (link.StartsWith("mailto")) continue;
|
|
||||||
|
|
||||||
using var client = new HttpClient();
|
|
||||||
var response = await client.GetAsync(link);
|
|
||||||
|
|
||||||
if (!response.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
CheckPassed(false,
|
|
||||||
new TestMessage
|
|
||||||
{
|
|
||||||
Color = "red", Title = "Bad Link",
|
|
||||||
Description = $"{link} failed on page {page.Url} with status code {response.StatusCode}"
|
|
||||||
});
|
|
||||||
Console.WriteLine(response.StatusCode.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
CheckPassed(false,
|
|
||||||
new TestMessage
|
|
||||||
{
|
|
||||||
Color = "red", Title = "Bad Link",
|
|
||||||
Description = $"{link} failed on page {page.Url} with stacktrace {e.StackTrace}"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void CheckPassed(bool passed, TestMessage message)
|
|
||||||
{
|
|
||||||
if (passed) return;
|
|
||||||
Tests.Last().Result = false;
|
|
||||||
Tests.Last().Messages.Add(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool DidTestsPass()
|
|
||||||
{
|
|
||||||
foreach (var test in Tests)
|
|
||||||
{
|
|
||||||
if (test.Result) continue;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<object> GetMessages()
|
|
||||||
{
|
|
||||||
if (DidTestsPass())
|
|
||||||
return new List<object>
|
|
||||||
{
|
|
||||||
new
|
|
||||||
{
|
|
||||||
title = "Passed",
|
|
||||||
color = int.Parse("00FF00", NumberStyles.HexNumber),
|
|
||||||
description = $"All {Tests.Count} tests passed."
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var messageList = new List<object>();
|
|
||||||
foreach (var test in Tests)
|
|
||||||
foreach (var message in test.Messages)
|
|
||||||
messageList.Add(
|
|
||||||
new
|
|
||||||
{
|
|
||||||
title = message.Title,
|
|
||||||
color = int.Parse(message.Color, NumberStyles.HexNumber),
|
|
||||||
description = message.Description
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
return messageList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
global using NUnit.Framework;
|
|
||||||
global using OpenQA.Selenium;
|
|
||||||
global using OpenQA.Selenium.Firefox;
|
|
||||||
global using OpenQA.Selenium.Chrome;
|
|
||||||
global using TestAutomation.Pages;
|
|
||||||
global using OpenQA.Selenium.Support.UI;
|
|
||||||
global using OpenQA.Selenium.Support;
|
|
||||||
@@ -1,216 +0,0 @@
|
|||||||
using System.Collections.ObjectModel;
|
|
||||||
using OpenQA.Selenium.Interactions;
|
|
||||||
using TestAutomation.Enums;
|
|
||||||
using TestAutomation.Shared;
|
|
||||||
|
|
||||||
namespace TestAutomation.Utils;
|
|
||||||
|
|
||||||
public class Website
|
|
||||||
{
|
|
||||||
public static readonly DeploymentType DeploymentType =
|
|
||||||
Environment.GetEnvironmentVariable("TEST_HOOK")!.Contains("localhost")
|
|
||||||
? DeploymentType.Local
|
|
||||||
: DeploymentType.Dev;
|
|
||||||
|
|
||||||
public static readonly string Url =
|
|
||||||
DeploymentType.Equals(DeploymentType.Dev)
|
|
||||||
? "https://calm-mud-04916b210.1.azurestaticapps.net"
|
|
||||||
: "https://localhost:7234";
|
|
||||||
|
|
||||||
public readonly ScreenType ScreenType = ScreenType.Desktop;
|
|
||||||
|
|
||||||
public Website(IWebDriver webDriver, TestReport testReport)
|
|
||||||
{
|
|
||||||
WebDriver = webDriver;
|
|
||||||
TestReport = testReport;
|
|
||||||
|
|
||||||
// Pages
|
|
||||||
HarassCalculatorPage = new HarassCalculatorPage(this);
|
|
||||||
DatabasePage = new DatabasePage(this);
|
|
||||||
DatabaseSinglePage = new DatabaseSinglePage(this);
|
|
||||||
|
|
||||||
// Navigation
|
|
||||||
NavigationBar = new NavigationBar(this);
|
|
||||||
|
|
||||||
// Dialogs
|
|
||||||
WebsiteSearchDialog = new WebsiteSearchDialog(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TestReport TestReport { get; set; }
|
|
||||||
|
|
||||||
public IWebDriver WebDriver { get; }
|
|
||||||
|
|
||||||
public HarassCalculatorPage HarassCalculatorPage { get; }
|
|
||||||
public DatabaseSinglePage DatabaseSinglePage { get; }
|
|
||||||
public DatabasePage DatabasePage { get; }
|
|
||||||
public NavigationBar NavigationBar { get; }
|
|
||||||
public WebsiteSearchDialog WebsiteSearchDialog { get; }
|
|
||||||
|
|
||||||
public IWebElement FindScreenSpecific(string byId)
|
|
||||||
{
|
|
||||||
var screenSpecificId = $"{ScreenType.ToString().ToLower()}-{byId}";
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return WebDriver.FindElement(By.Id(screenSpecificId));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new Exception($"Couldn't find {screenSpecificId}. Element does not exist on current page. " +
|
|
||||||
"\n\nPerhaps an Id is missing.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public IWebElement Find(string byId, string withParentId)
|
|
||||||
{
|
|
||||||
IWebElement parent;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
parent = WebDriver.FindElement(By.Id(withParentId));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new Exception($"Couldn't find parent {withParentId}. Element does not exist on current page. " +
|
|
||||||
"\n\nPerhaps an Id is missing.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return parent.FindElement(By.Id(byId));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new Exception($"Couldn't find {byId}. Element does not exist on current page. " +
|
|
||||||
"\n\nPerhaps an Id is missing.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IWebElement Find(string byId)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return WebDriver.FindElement(By.Id(byId));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new Exception($"Couldn't find {byId}. Element does not exist on current page. " +
|
|
||||||
"\n\nPerhaps an Id is missing.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReadOnlyCollection<IWebElement> FindAll(string byId)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return WebDriver.FindElements(By.Id(byId));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new Exception($"Couldn't find {byId}. Element does not exist on current page. " +
|
|
||||||
"\n\nPerhaps an Id is missing.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReadOnlyCollection<IWebElement> FindAllWithTag(string tag)
|
|
||||||
{
|
|
||||||
return WebDriver.FindElements(By.TagName(tag));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReadOnlyCollection<IWebElement> FindAllWithTag(IWebElement parent, string tag)
|
|
||||||
{
|
|
||||||
return parent.FindElements(By.TagName(tag));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public IWebElement FindButtonWithLabel(string label)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return WebDriver.FindElement(By.XPath($"//button[@label='{label}']"));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new Exception($"Couldn't find with label: {label}. Element does not exist on current page. ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//@FindBy(xpath = "//div[@label='First Name']")
|
|
||||||
|
|
||||||
public IList<IWebElement> FindChildren(string ofId, string tagname)
|
|
||||||
{
|
|
||||||
return WebDriver.FindElements(By.CssSelector($"#{ofId} {tagname}"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public string FindText(string byId)
|
|
||||||
{
|
|
||||||
return WebDriver.FindElement(By.Id(byId)).Text;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int FindInt(string byId)
|
|
||||||
{
|
|
||||||
return int.Parse(WebDriver.FindElement(By.Id(byId)).Text);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void ClickTopLeft()
|
|
||||||
{
|
|
||||||
new Actions(WebDriver)
|
|
||||||
.MoveByOffset(32, 32)
|
|
||||||
.Click()
|
|
||||||
.Perform();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IWebElement Click(IWebElement element)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
element.Click();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
throw new Exception($"Couldn't click on {element.GetDomProperty("id")}. ");
|
|
||||||
}
|
|
||||||
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public IWebElement EnterInput<T>(IWebElement element, T input)
|
|
||||||
{
|
|
||||||
element.Clear();
|
|
||||||
element.SendKeys(input!.ToString());
|
|
||||||
element.SendKeys(Keys.Enter);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public IWebElement EnterInput<T>(string byId, T input)
|
|
||||||
{
|
|
||||||
var element = Find(byId);
|
|
||||||
element.Clear();
|
|
||||||
element.SendKeys(input!.ToString());
|
|
||||||
element.SendKeys(Keys.Enter);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetLabel(string byId)
|
|
||||||
{
|
|
||||||
return Find(byId).Text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Website Goto()
|
|
||||||
{
|
|
||||||
WebDriver.Navigate().GoToUrl($"{Url}");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Goto(string path)
|
|
||||||
{
|
|
||||||
var url = $"{Url}/{path}";
|
|
||||||
|
|
||||||
WebDriver.Navigate().GoToUrl($"{url}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
using System.Text;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace TestAutomation;
|
|
||||||
|
|
||||||
[SetUpFixture]
|
|
||||||
public class Tests : BaseTest
|
|
||||||
{
|
|
||||||
[OneTimeSetUp]
|
|
||||||
public void Setup()
|
|
||||||
{
|
|
||||||
Website.Goto();
|
|
||||||
Website.WebDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(15);
|
|
||||||
}
|
|
||||||
|
|
||||||
[OneTimeTearDown]
|
|
||||||
public void TearDown()
|
|
||||||
{
|
|
||||||
Website.WebDriver.Quit();
|
|
||||||
|
|
||||||
var message = new
|
|
||||||
{
|
|
||||||
content = "Test Report " + DateTime.Now.ToString("dd/MM/yyyy"),
|
|
||||||
embeds = TestReport.GetMessages()
|
|
||||||
};
|
|
||||||
|
|
||||||
var content = new StringContent(JsonConvert.SerializeObject(message), Encoding.UTF8, "application/json");
|
|
||||||
|
|
||||||
if (Environment.GetEnvironmentVariable("TEST_HOOK") == null) return;
|
|
||||||
|
|
||||||
HttpClient.PostAsync(Environment.GetEnvironmentVariable("TEST_HOOK"), content).Wait();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user