test(SearchTest) Added a test for opening and closing search dialog
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IJSRuntime JsRuntime
|
@inject IJSRuntime JsRuntime
|
||||||
|
|
||||||
<button class="searchButtonContainer" @onclick="ButtonClicked">
|
<button id="@Id" class="searchButtonContainer" @onclick="ButtonClicked">
|
||||||
<div class="searchText">
|
<div class="searchText">
|
||||||
Search...
|
Search...
|
||||||
</div>
|
</div>
|
||||||
@@ -33,15 +33,15 @@
|
|||||||
background-color: var(--info);
|
background-color: var(--info);
|
||||||
border: 2px solid var(--primary-border);
|
border: 2px solid var(--primary-border);
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public RenderFragment ChildContent { get; set; } = default!;
|
public RenderFragment ChildContent { get; set; } = default!;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Id { get; set; } = default!;
|
||||||
|
|
||||||
private string userAgent = "";
|
private string userAgent = "";
|
||||||
|
|
||||||
string CommandKey => userAgent.Contains("Mac OS") ? "CMD" : "Ctrl";
|
string CommandKey => userAgent.Contains("Mac OS") ? "CMD" : "Ctrl";
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
@inject ISearchService SearchService
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject IJSRuntime JsRuntime
|
||||||
|
|
||||||
|
<button id="@Id" class="searchIconButtonContainer" @onclick="ButtonClicked">
|
||||||
|
<div class="searchText">
|
||||||
|
S
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.searchIconButtonContainer {
|
||||||
|
background-color: var(--primary);
|
||||||
|
border: 2px solid var(--primary-border);
|
||||||
|
border-radius: 8px;
|
||||||
|
font-weight: 800;
|
||||||
|
width: 32px;
|
||||||
|
padding: 5px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public RenderFragment ChildContent { get; set; } = default!;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Id { get; set; } = default!;
|
||||||
|
|
||||||
|
private void ButtonClicked(EventArgs eventArgs)
|
||||||
|
{
|
||||||
|
SearchService.Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
@inherits LayoutComponentBase
|
@inherits LayoutComponentBase
|
||||||
@inject INavigationService navigationService
|
@inject INavigationService NavigationService
|
||||||
@implements IDisposable
|
@implements IDisposable
|
||||||
|
|
||||||
@{
|
@{
|
||||||
var visibleStyle = navigationService.GetNavigationSectionId() > 0 ? "clickOffVisible" : "";
|
var visibleStyle = NavigationService.GetNavigationSectionId() > 0 ? "clickOffVisible" : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
<div onclick="@MenuClosed" class="clickOffBackground @visibleStyle">
|
<div onclick="@MenuClosed" class="clickOffBackground @visibleStyle">
|
||||||
@@ -12,14 +12,14 @@
|
|||||||
|
|
||||||
<div class="desktopNavContainer">
|
<div class="desktopNavContainer">
|
||||||
<div class="menuHeader">
|
<div class="menuHeader">
|
||||||
<NavLink href="/" class="websiteTitle">
|
<NavLink id="desktop-homeLink" href="/" class="websiteTitle">
|
||||||
IGP Fan Reference
|
IGP Fan Reference
|
||||||
</NavLink>
|
</NavLink>
|
||||||
|
|
||||||
<div class="sectionNavs">
|
<div class="sectionNavs">
|
||||||
@foreach (var webSection in WebSections)
|
@foreach (var webSection in WebSections)
|
||||||
{
|
{
|
||||||
var isSelected = navigationService.GetNavigationSectionId().Equals(webSection.Id);
|
var isSelected = NavigationService.GetNavigationSectionId().Equals(webSection.Id);
|
||||||
var sectionButtonStyle = "sectionButton";
|
var sectionButtonStyle = "sectionButton";
|
||||||
if (isSelected)
|
if (isSelected)
|
||||||
{
|
{
|
||||||
@@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
<div class="sectionNav">
|
<div class="sectionNav">
|
||||||
<button onclick="@(() => { MenuClicked(webSection.Id); })" class="@sectionButtonStyle">@webSection.Name</button>
|
<button onclick="@(() => { MenuClicked(webSection.Id); })" class="@sectionButtonStyle">@webSection.Name</button>
|
||||||
|
|
||||||
@if (isSelected)
|
@if (isSelected)
|
||||||
{
|
{
|
||||||
<div class="navMenuPosition">
|
<div class="navMenuPosition">
|
||||||
@@ -41,7 +40,7 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<SearchButtonComponent/>
|
<SearchButtonComponent Id="desktop-searchButton"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -169,27 +168,27 @@
|
|||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
base.OnInitialized();
|
base.OnInitialized();
|
||||||
navigationService.Subscribe(StateHasChanged);
|
NavigationService.Subscribe(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDisposable.Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
navigationService.Unsubscribe(StateHasChanged);
|
NavigationService.Unsubscribe(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuClicked(int menuName)
|
void MenuClicked(int menuName)
|
||||||
{
|
{
|
||||||
navigationService.ChangeNavigationSectionId(menuName);
|
NavigationService.ChangeNavigationSectionId(menuName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuClosed()
|
void MenuClosed()
|
||||||
{
|
{
|
||||||
navigationService.ChangeNavigationSectionId(-1);
|
NavigationService.ChangeNavigationSectionId(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HoverOut(MouseEventArgs mouseEventArgs)
|
void HoverOut(MouseEventArgs mouseEventArgs)
|
||||||
{
|
{
|
||||||
navigationService.ChangeNavigationState(NavigationStateType.Default);
|
NavigationService.ChangeNavigationState(NavigationStateType.Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
<div class="mobileFooter">
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="mobileFooter">
|
||||||
<div class="mobileNavSectionsContainer">
|
<div class="mobileNavSectionsContainer">
|
||||||
@foreach (var webSection in WebSections)
|
@foreach (var webSection in WebSections)
|
||||||
{
|
{
|
||||||
@@ -8,6 +11,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
<SearchIconButtonComponent/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="fullPageButton @(selectedSection != null)" @onclick="OnPageClicked" @onclick:stopPropagation="false" @onclick:preventDefault="false">
|
<div class="fullPageButton @(selectedSection != null)" @onclick="OnPageClicked" @onclick:stopPropagation="false" @onclick:preventDefault="false">
|
||||||
@@ -52,6 +56,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.mobileFooter {
|
.mobileFooter {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
background-color: rgba(0,0,0,1);
|
background-color: rgba(0,0,0,1);
|
||||||
|
|||||||
@@ -5,13 +5,16 @@
|
|||||||
<div class="tabletTitle">
|
<div class="tabletTitle">
|
||||||
IGP Fan Reference
|
IGP Fan Reference
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tabletButtons">
|
||||||
|
|
||||||
|
<SearchButtonComponent/>
|
||||||
<div class="tabletButton">
|
<div class="tabletButton">
|
||||||
<div class="tabletMenuTitle">
|
<div class="tabletMenuTitle">
|
||||||
Menu
|
Menu
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="fullPageButton @navOpen" @onclick="OnNavClicked" @onclick:stopPropagation="false" @onclick:preventDefault="false">
|
<div class="fullPageButton @navOpen" @onclick="OnNavClicked" @onclick:stopPropagation="false" @onclick:preventDefault="false">
|
||||||
@@ -79,6 +82,12 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tabletButtons {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.tabletNavItem {
|
.tabletNavItem {
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
@if (searchService.IsLoaded() && searchService.IsVisible)
|
@if (searchService.IsLoaded() && searchService.IsVisible)
|
||||||
{
|
{
|
||||||
<div class="searchBackground" onclick="@CloseDialog">
|
<div id="searchBackground" class="searchBackground" onclick="@CloseDialog">
|
||||||
<div class="searchContainer"
|
<div class="searchContainer"
|
||||||
@onclick:preventDefault="true"
|
@onclick:preventDefault="true"
|
||||||
@onclick:stopPropagation="true">
|
@onclick:stopPropagation="true">
|
||||||
@@ -33,7 +33,11 @@
|
|||||||
<div class="searchContents">
|
<div class="searchContents">
|
||||||
@foreach (var searchPoint in searchPoints)
|
@foreach (var searchPoint in searchPoints)
|
||||||
{
|
{
|
||||||
<button class="searchLink @searchPoint.PointType.ToLower()" @onclick="() => OnSearch(searchPoint)">@searchPoint.Title</button>
|
<button class="searchLink @searchPoint.PointType.ToLower()"
|
||||||
|
label="@searchPoint.Title"
|
||||||
|
@onclick="() => OnSearch(searchPoint)">
|
||||||
|
@searchPoint.Title
|
||||||
|
</button>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,51 @@
|
|||||||
|
using TestAutomation.Utils;
|
||||||
|
|
||||||
|
namespace TestAutomation;
|
||||||
|
|
||||||
|
public enum DeploymentType
|
||||||
|
{
|
||||||
|
Dev,
|
||||||
|
Local
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BaseTest
|
||||||
|
{
|
||||||
|
protected static readonly DeploymentType DeploymentType =
|
||||||
|
Environment.GetEnvironmentVariable("TEST_HOOK") != null
|
||||||
|
? DeploymentType.Dev
|
||||||
|
: DeploymentType.Local;
|
||||||
|
|
||||||
|
protected static readonly string WebsiteUrl =
|
||||||
|
DeploymentType.Equals(DeploymentType.Dev)
|
||||||
|
? "https://calm-mud-04916b210.1.azurestaticapps.net/"
|
||||||
|
: "https://localhost:7234";
|
||||||
|
|
||||||
|
protected static readonly TestReport TestReport = new();
|
||||||
|
|
||||||
|
|
||||||
|
protected static Website WebsiteInstance = default!;
|
||||||
|
|
||||||
|
protected static Website Website
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (WebsiteInstance == null)
|
||||||
|
{
|
||||||
|
var options = new FirefoxOptions();
|
||||||
|
|
||||||
|
options.AcceptInsecureCertificates = true;
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return WebsiteInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace TestAutomation.Enums;
|
||||||
|
|
||||||
|
public enum ScreenType
|
||||||
|
{
|
||||||
|
Desktop,
|
||||||
|
Tablet,
|
||||||
|
Mobile
|
||||||
|
}
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
using TestAutomation.Utils;
|
|
||||||
|
|
||||||
namespace TestAutomation.Pages;
|
|
||||||
|
|
||||||
public class BasePage {
|
|
||||||
public Website website;
|
|
||||||
|
|
||||||
public BasePage(Website website) {
|
|
||||||
this.website = website;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using TestAutomation.Shared;
|
||||||
|
using TestAutomation.Utils;
|
||||||
|
|
||||||
|
namespace TestAutomation.Pages;
|
||||||
|
|
||||||
|
public class DatabaseSinglePage : BaseElement
|
||||||
|
{
|
||||||
|
public DatabaseSinglePage(Website website) : base(website) { }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,71 +1,86 @@
|
|||||||
using TestAutomation.Utils;
|
using TestAutomation.Shared;
|
||||||
|
using TestAutomation.Utils;
|
||||||
|
|
||||||
namespace TestAutomation.Pages;
|
namespace TestAutomation.Pages;
|
||||||
|
|
||||||
public class HarassCalculatorPage : BasePage {
|
public class HarassCalculatorPage : BaseElement
|
||||||
public HarassCalculatorPage(Website website) : base(website) { }
|
{
|
||||||
private IWebElement NumberOfWorkersLostToHarass => website.Find("numberOfWorkersLostToHarass");
|
public HarassCalculatorPage(Website website) : base(website)
|
||||||
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 IWebElement NumberOfWorkersLostToHarass => Website.Find("numberOfWorkersLostToHarass");
|
||||||
private int ExampleWorkerCost => website.FindInt("exampleWorkerCost");
|
private IWebElement NumberOfTownHallsExisting => Website.Find("numberOfTownHallsExisting");
|
||||||
private int ExampleMiningTimeCost => website.FindInt("exampleMiningTimeCost");
|
private IList<IWebElement> OnTownHallTravelTimes => Website.FindChildren("numberOfTownHallTravelTimes", "input");
|
||||||
private int ExampleTotalAlloyLossDifference => website.FindInt("exampleTotalAlloyLossDifference");
|
private int TotalAlloyHarassment => Website.FindInt("totalAlloyHarassment");
|
||||||
private int ExampleTotalAlloyLossAccurate => website.FindInt("exampleTotalAlloyLossAccurate");
|
private int WorkerReplacementCost => Website.FindInt("workerReplacementCost");
|
||||||
private int ExampleTotalAlloyLossAccurateDifference => website.FindInt("exampleTotalAlloyLossAccurateDifference");
|
private int DelayedMiningCost => Website.FindInt("delayedMiningCost");
|
||||||
|
private int AverageTravelTime => Website.FindInt("getAverageTravelTime");
|
||||||
|
|
||||||
public HarassCalculatorPage SetWorkersLostToHarass(int number) {
|
private int ExampleTotalAlloyLoss => Website.FindInt("exampleTotalAlloyLoss");
|
||||||
website.EnterInput(NumberOfWorkersLostToHarass, number);
|
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 HarassCalculatorPage SetWorkersLostToHarass(int number)
|
||||||
|
{
|
||||||
|
Website.EnterInput(NumberOfWorkersLostToHarass, number);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HarassCalculatorPage SetNumberOfTownHallsExisting(int number) {
|
public HarassCalculatorPage SetNumberOfTownHallsExisting(int number)
|
||||||
website.EnterInput(NumberOfTownHallsExisting, number);
|
{
|
||||||
|
Website.EnterInput(NumberOfTownHallsExisting, number);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HarassCalculatorPage SetTownHallTravelTime(int forTownHall, int number) {
|
public HarassCalculatorPage SetTownHallTravelTime(int forTownHall, int number)
|
||||||
website.EnterInput(OnTownHallTravelTimes[forTownHall], number);
|
{
|
||||||
|
Website.EnterInput(OnTownHallTravelTimes[forTownHall], number);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HarassCalculatorPage GetTotalAlloyHarassment(out int result) {
|
public HarassCalculatorPage GetTotalAlloyHarassment(out int result)
|
||||||
|
{
|
||||||
result = TotalAlloyHarassment;
|
result = TotalAlloyHarassment;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public HarassCalculatorPage GetExampleTotalAlloyLoss(out int result) {
|
public HarassCalculatorPage GetExampleTotalAlloyLoss(out int result)
|
||||||
|
{
|
||||||
result = ExampleTotalAlloyLoss;
|
result = ExampleTotalAlloyLoss;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HarassCalculatorPage GetExampleWorkerCost(out int result) {
|
public HarassCalculatorPage GetExampleWorkerCost(out int result)
|
||||||
|
{
|
||||||
result = ExampleWorkerCost;
|
result = ExampleWorkerCost;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HarassCalculatorPage GetExampleMiningTimeCost(out int result) {
|
public HarassCalculatorPage GetExampleMiningTimeCost(out int result)
|
||||||
|
{
|
||||||
result = ExampleMiningTimeCost;
|
result = ExampleMiningTimeCost;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HarassCalculatorPage GetExampleTotalAlloyLossAccurate(out int result) {
|
public HarassCalculatorPage GetExampleTotalAlloyLossAccurate(out int result)
|
||||||
|
{
|
||||||
result = ExampleTotalAlloyLossAccurate;
|
result = ExampleTotalAlloyLossAccurate;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HarassCalculatorPage GetExampleTotalAlloyLossDifference(out int result) {
|
public HarassCalculatorPage GetExampleTotalAlloyLossDifference(out int result)
|
||||||
|
{
|
||||||
result = ExampleTotalAlloyLossDifference;
|
result = ExampleTotalAlloyLossDifference;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HarassCalculatorPage GetExampleTotalAlloyLossAccurateDifference(out int result) {
|
public HarassCalculatorPage GetExampleTotalAlloyLossAccurateDifference(out int result)
|
||||||
|
{
|
||||||
result = ExampleTotalAlloyLossAccurateDifference;
|
result = ExampleTotalAlloyLossAccurateDifference;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using TestAutomation.Utils;
|
||||||
|
|
||||||
|
namespace TestAutomation.Shared;
|
||||||
|
|
||||||
|
public class BaseElement
|
||||||
|
{
|
||||||
|
protected readonly Website Website;
|
||||||
|
|
||||||
|
protected BaseElement(Website website)
|
||||||
|
{
|
||||||
|
Website = website;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using TestAutomation.Enums;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using Discord.Rest;
|
||||||
|
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 void SelectSearchEntity(string throne)
|
||||||
|
{
|
||||||
|
Website.Click(Website.FindButtonWithLabel(throne));
|
||||||
|
//TODO Add DatabaseSinglePage
|
||||||
|
//return Website.DatabaseSinglePage;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,89 +1,45 @@
|
|||||||
using System.Text;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using TestAutomation.Utils;
|
using TestAutomation.Utils;
|
||||||
|
|
||||||
namespace TestAutomation;
|
namespace TestAutomation;
|
||||||
|
|
||||||
public class Tests {
|
[TestFixture]
|
||||||
private readonly IWebDriver _webDriver = default!;
|
public class TestHarassCalculator : BaseTest
|
||||||
private readonly string develop = "https://calm-mud-04916b210.1.azurestaticapps.net/";
|
{
|
||||||
|
|
||||||
private readonly HttpClient httpClient = new();
|
|
||||||
|
|
||||||
|
|
||||||
private readonly string localhost = "https://localhost:7234";
|
|
||||||
|
|
||||||
private readonly TestReport testReport = new();
|
|
||||||
|
|
||||||
public Tests() {
|
|
||||||
var options = new FirefoxOptions();
|
|
||||||
|
|
||||||
options.AcceptInsecureCertificates = true;
|
|
||||||
options.AddArgument("--headless");
|
|
||||||
options.AddArgument("--ignore-certificate-errors");
|
|
||||||
options.AddArgument("--start-maximized");
|
|
||||||
options.AddArgument("--test-type");
|
|
||||||
options.AddArgument("--allow-running-insecure-content");
|
|
||||||
|
|
||||||
_webDriver = new FirefoxDriver(Environment.CurrentDirectory, options);
|
|
||||||
|
|
||||||
Website = new Website(_webDriver);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Website Website { get; }
|
|
||||||
|
|
||||||
[OneTimeSetUp]
|
|
||||||
public void Setup() {
|
|
||||||
_webDriver.Navigate().GoToUrl(develop);
|
|
||||||
_webDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(15);
|
|
||||||
}
|
|
||||||
|
|
||||||
[OneTimeTearDown]
|
|
||||||
public void TearDown() {
|
|
||||||
_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");
|
|
||||||
|
|
||||||
httpClient.PostAsync(Environment.GetEnvironmentVariable("TEST_HOOK"), content).Wait();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void HarassCalculator() {
|
public void CalculatorInput()
|
||||||
testReport.CreateTest();
|
{
|
||||||
|
TestReport.CreateTest();
|
||||||
|
|
||||||
_webDriver.Navigate().GoToUrl(develop + "/harass-calculator");
|
Website.WebDriver.Navigate().GoToUrl(WebsiteUrl + "/harass-calculator");
|
||||||
|
|
||||||
var expectedTotalAlloyHarassment = 240;
|
var expectedTotalAlloyHarassment = 240;
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
Website.HarassCalculatorPage
|
Website.HarassCalculatorPage
|
||||||
.SetWorkersLostToHarass(3)
|
.SetWorkersLostToHarass(3)
|
||||||
.SetNumberOfTownHallsExisting(2)
|
.SetNumberOfTownHallsExisting(2)
|
||||||
.SetTownHallTravelTime(0, 30)
|
.SetTownHallTravelTime(0, 30)
|
||||||
.GetTotalAlloyHarassment(out var foundTotalAlloyHarassment);
|
.GetTotalAlloyHarassment(out var foundTotalAlloyHarassment);
|
||||||
|
|
||||||
testReport.CheckPassed(expectedTotalAlloyHarassment.Equals(foundTotalAlloyHarassment),
|
TestReport.CheckPassed(expectedTotalAlloyHarassment.Equals(foundTotalAlloyHarassment),
|
||||||
TestMessage.CreateFailedMessage($"expectTotalAlloyHarassment of {expectedTotalAlloyHarassment} " +
|
TestMessage.CreateFailedMessage($"expectTotalAlloyHarassment of {expectedTotalAlloyHarassment} " +
|
||||||
"does not equal " +
|
"does not equal " +
|
||||||
$"foundTotalAlloyHarassment of {foundTotalAlloyHarassment} "));
|
$"foundTotalAlloyHarassment of {foundTotalAlloyHarassment} "));
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e)
|
||||||
testReport.CheckPassed(false,
|
{
|
||||||
|
TestReport.CheckPassed(false,
|
||||||
TestMessage.CreateFailedMessage(e.StackTrace!));
|
TestMessage.CreateFailedMessage(e.StackTrace!));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void HarassCalculatorInformation() {
|
public void CalculatedExampleInformation()
|
||||||
testReport.CreateTest();
|
{
|
||||||
|
TestReport.CreateTest();
|
||||||
|
|
||||||
_webDriver.Navigate().GoToUrl(develop + "/harass-calculator");
|
Website.WebDriver.Navigate().GoToUrl(WebsiteUrl + "/harass-calculator");
|
||||||
|
|
||||||
var expectedExampleTotalAlloyLoss = 720;
|
var expectedExampleTotalAlloyLoss = 720;
|
||||||
var expectedExampleWorkerCost = 300;
|
var expectedExampleWorkerCost = 300;
|
||||||
@@ -100,38 +56,38 @@ public class Tests {
|
|||||||
.GetExampleTotalAlloyLossDifference(out var foundGetExampleTotalAlloyLossDifference)
|
.GetExampleTotalAlloyLossDifference(out var foundGetExampleTotalAlloyLossDifference)
|
||||||
.GetExampleTotalAlloyLossAccurateDifference(out var foundExampleTotalAlloyLossAccurateDifference);
|
.GetExampleTotalAlloyLossAccurateDifference(out var foundExampleTotalAlloyLossAccurateDifference);
|
||||||
|
|
||||||
testReport.CheckPassed(expectedExampleTotalAlloyLoss.Equals(foundTotalAlloyLoss),
|
TestReport.CheckPassed(expectedExampleTotalAlloyLoss.Equals(foundTotalAlloyLoss),
|
||||||
TestMessage.CreateFailedMessage($"expectedExampleTotalAlloyLoss of {expectedExampleTotalAlloyLoss} " +
|
TestMessage.CreateFailedMessage($"expectedExampleTotalAlloyLoss of {expectedExampleTotalAlloyLoss} " +
|
||||||
"does not equal " +
|
"does not equal " +
|
||||||
$"foundTotalAlloyLoss of {foundTotalAlloyLoss} "));
|
$"foundTotalAlloyLoss of {foundTotalAlloyLoss} "));
|
||||||
|
|
||||||
testReport.CheckPassed(expectedExampleWorkerCost.Equals(foundExampleWorkerCost),
|
TestReport.CheckPassed(expectedExampleWorkerCost.Equals(foundExampleWorkerCost),
|
||||||
TestMessage.CreateFailedMessage($"expectedExampleWorkerCost of {expectedExampleWorkerCost} " +
|
TestMessage.CreateFailedMessage($"expectedExampleWorkerCost of {expectedExampleWorkerCost} " +
|
||||||
"does not equal " +
|
"does not equal " +
|
||||||
$"foundExampleWorkerCost of {foundExampleWorkerCost} "));
|
$"foundExampleWorkerCost of {foundExampleWorkerCost} "));
|
||||||
|
|
||||||
|
|
||||||
testReport.CheckPassed(expectedExampleMiningTimeCost.Equals(foundExampleMiningTimeCost),
|
TestReport.CheckPassed(expectedExampleMiningTimeCost.Equals(foundExampleMiningTimeCost),
|
||||||
TestMessage.CreateFailedMessage($"expectedExampleMiningTimeCost of {expectedExampleMiningTimeCost} " +
|
TestMessage.CreateFailedMessage($"expectedExampleMiningTimeCost of {expectedExampleMiningTimeCost} " +
|
||||||
"does not equal " +
|
"does not equal " +
|
||||||
$"foundExampleMiningTimeCost of {foundExampleMiningTimeCost} "));
|
$"foundExampleMiningTimeCost of {foundExampleMiningTimeCost} "));
|
||||||
|
|
||||||
|
|
||||||
testReport.CheckPassed(expectedExampleTotalAlloyLossAccurate.Equals(foundExampleTotalAlloyLossAccurate),
|
TestReport.CheckPassed(expectedExampleTotalAlloyLossAccurate.Equals(foundExampleTotalAlloyLossAccurate),
|
||||||
TestMessage.CreateFailedMessage(
|
TestMessage.CreateFailedMessage(
|
||||||
$"expectedExampleTotalAlloyLossAccurate of {expectedExampleTotalAlloyLossAccurate} " +
|
$"expectedExampleTotalAlloyLossAccurate of {expectedExampleTotalAlloyLossAccurate} " +
|
||||||
"does not equal " +
|
"does not equal " +
|
||||||
$"foundExampleTotalAlloyLossAccurate of {foundExampleTotalAlloyLossAccurate} "));
|
$"foundExampleTotalAlloyLossAccurate of {foundExampleTotalAlloyLossAccurate} "));
|
||||||
|
|
||||||
|
|
||||||
testReport.CheckPassed(expectedExampleTotalAlloyLossDifference.Equals(foundGetExampleTotalAlloyLossDifference),
|
TestReport.CheckPassed(expectedExampleTotalAlloyLossDifference.Equals(foundGetExampleTotalAlloyLossDifference),
|
||||||
TestMessage.CreateFailedMessage(
|
TestMessage.CreateFailedMessage(
|
||||||
$"expectedExampleTotalAlloyLossDifference of {expectedExampleTotalAlloyLossDifference} " +
|
$"expectedExampleTotalAlloyLossDifference of {expectedExampleTotalAlloyLossDifference} " +
|
||||||
"does not equal " +
|
"does not equal " +
|
||||||
$"foundGetExampleTotalAlloyLossDifference of {foundGetExampleTotalAlloyLossDifference} "));
|
$"foundGetExampleTotalAlloyLossDifference of {foundGetExampleTotalAlloyLossDifference} "));
|
||||||
|
|
||||||
|
|
||||||
testReport.CheckPassed(
|
TestReport.CheckPassed(
|
||||||
expectedExampleTotalAlloyLossAccurateDifference.Equals(foundExampleTotalAlloyLossAccurateDifference),
|
expectedExampleTotalAlloyLossAccurateDifference.Equals(foundExampleTotalAlloyLossAccurateDifference),
|
||||||
TestMessage.CreateFailedMessage(
|
TestMessage.CreateFailedMessage(
|
||||||
$"expectedExampleTotalAlloyLossAccurateDifference of {expectedExampleTotalAlloyLossAccurateDifference} " +
|
$"expectedExampleTotalAlloyLossAccurateDifference of {expectedExampleTotalAlloyLossAccurateDifference} " +
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
namespace TestAutomation;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class TestSearchFeatures : BaseTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void DesktopOpenCloseSearchDialog()
|
||||||
|
{
|
||||||
|
TestReport.CreateTest();
|
||||||
|
|
||||||
|
Website.WebDriver.Navigate().GoToUrl(WebsiteUrl + "/");
|
||||||
|
|
||||||
|
Website.NavigationBar
|
||||||
|
.ClickSearchButton()
|
||||||
|
.CloseDialog()
|
||||||
|
.ClickHomeLink();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[Ignore("Not completed")]
|
||||||
|
public void DesktopSearchForThrone()
|
||||||
|
{
|
||||||
|
TestReport.CreateTest();
|
||||||
|
|
||||||
|
Website.WebDriver.Navigate().GoToUrl(WebsiteUrl + "/");
|
||||||
|
|
||||||
|
Website.NavigationBar
|
||||||
|
.ClickSearchButton()
|
||||||
|
.Search("Throne")
|
||||||
|
.SelectSearchEntity("Throne");
|
||||||
|
// .GetName(out var name);
|
||||||
|
|
||||||
|
// TestReport.CheckPassed(name.Equals("Throne"), "Couldn't find Throne via search.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Text;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace TestAutomation;
|
||||||
|
|
||||||
|
[SetUpFixture]
|
||||||
|
public class Tests : BaseTest
|
||||||
|
{
|
||||||
|
[OneTimeSetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
Website.WebDriver.Navigate().GoToUrl(WebsiteUrl);
|
||||||
|
Website.WebDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(15);
|
||||||
|
}
|
||||||
|
|
||||||
|
[OneTimeTearDown]
|
||||||
|
public void TearDown()
|
||||||
|
{
|
||||||
|
HttpClient HttpClient = new();
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
namespace TestAutomation.Utils;
|
namespace TestAutomation.Utils;
|
||||||
|
|
||||||
public class Test {
|
public class Test
|
||||||
|
{
|
||||||
public string Name { get; set; } = "Name...";
|
public string Name { get; set; } = "Name...";
|
||||||
public bool Result { get; set; } = true;
|
public bool Result { get; set; } = true;
|
||||||
public IList<TestMessage> Messages { get; set; } = new List<TestMessage>();
|
public IList<TestMessage> Messages { get; set; } = new List<TestMessage>();
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
namespace TestAutomation.Utils;
|
namespace TestAutomation.Utils;
|
||||||
|
|
||||||
public class TestMessage {
|
public class TestMessage
|
||||||
|
{
|
||||||
public string Title { get; set; } = "Name...";
|
public string Title { get; set; } = "Name...";
|
||||||
public string Description { get; set; } = "";
|
public string Description { get; set; } = "";
|
||||||
public string Color { get; set; } = "FFFFFF";
|
public string Color { get; set; } = "FFFFFF";
|
||||||
|
|
||||||
public static TestMessage CreateFailedMessage(string description) {
|
public static TestMessage CreateFailedMessage(string description)
|
||||||
|
{
|
||||||
return new TestMessage { Title = "Check Failed", Description = description, Color = "FF0000" };
|
return new TestMessage { Title = "Check Failed", Description = description, Color = "FF0000" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,24 +4,31 @@ using System.Runtime.CompilerServices;
|
|||||||
|
|
||||||
namespace TestAutomation.Utils;
|
namespace TestAutomation.Utils;
|
||||||
|
|
||||||
public class TestReport {
|
public class TestReport
|
||||||
|
{
|
||||||
private List<Test> Tests { get; } = new();
|
private List<Test> Tests { get; } = new();
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
public Test CreateTest() {
|
public Test CreateTest()
|
||||||
|
{
|
||||||
var testName = new StackTrace().GetFrame(1)!.GetMethod()!.Name!;
|
var testName = new StackTrace().GetFrame(1)!.GetMethod()!.Name!;
|
||||||
Tests.Add(new Test { Name = testName });
|
Tests.Add(new Test { Name = testName });
|
||||||
return Tests.Last();
|
return Tests.Last();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckPassed(bool passed, TestMessage message) {
|
public void CheckPassed(bool passed, TestMessage message)
|
||||||
|
{
|
||||||
if (passed) return;
|
if (passed) return;
|
||||||
Tests.Last().Result = false;
|
Tests.Last().Result = false;
|
||||||
Tests.Last().Messages.Add(message);
|
Tests.Last().Messages.Add(message);
|
||||||
|
|
||||||
|
throw new Exception(message.Description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DidTestsPass() {
|
public bool DidTestsPass()
|
||||||
foreach (var test in Tests) {
|
{
|
||||||
|
foreach (var test in Tests)
|
||||||
|
{
|
||||||
if (test.Result) continue;
|
if (test.Result) continue;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -31,10 +38,13 @@ public class TestReport {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<object> GetMessages() {
|
public List<object> GetMessages()
|
||||||
|
{
|
||||||
if (DidTestsPass())
|
if (DidTestsPass())
|
||||||
return new List<object> {
|
return new List<object>
|
||||||
new {
|
{
|
||||||
|
new
|
||||||
|
{
|
||||||
title = "Passed",
|
title = "Passed",
|
||||||
color = int.Parse("00FF00", NumberStyles.HexNumber),
|
color = int.Parse("00FF00", NumberStyles.HexNumber),
|
||||||
description = $"All {Tests.Count} tests passed."
|
description = $"All {Tests.Count} tests passed."
|
||||||
@@ -45,7 +55,8 @@ public class TestReport {
|
|||||||
foreach (var test in Tests)
|
foreach (var test in Tests)
|
||||||
foreach (var message in test.Messages)
|
foreach (var message in test.Messages)
|
||||||
messageList.Add(
|
messageList.Add(
|
||||||
new {
|
new
|
||||||
|
{
|
||||||
title = message.Title,
|
title = message.Title,
|
||||||
color = int.Parse(message.Color, NumberStyles.HexNumber),
|
color = int.Parse(message.Color, NumberStyles.HexNumber),
|
||||||
description = message.Description
|
description = message.Description
|
||||||
|
|||||||
@@ -1,35 +1,113 @@
|
|||||||
namespace TestAutomation.Utils;
|
using OpenQA.Selenium.Interactions;
|
||||||
|
using TestAutomation.Enums;
|
||||||
|
using TestAutomation.Shared;
|
||||||
|
|
||||||
public class Website {
|
namespace TestAutomation.Utils;
|
||||||
public Website(IWebDriver webDriver) {
|
|
||||||
|
public class Website
|
||||||
|
{
|
||||||
|
public readonly ScreenType ScreenType = ScreenType.Desktop;
|
||||||
|
|
||||||
|
public Website(IWebDriver webDriver)
|
||||||
|
{
|
||||||
WebDriver = webDriver;
|
WebDriver = webDriver;
|
||||||
|
|
||||||
HarassCalculatorPage = new HarassCalculatorPage(this);
|
HarassCalculatorPage = new HarassCalculatorPage(this);
|
||||||
|
NavigationBar = new NavigationBar(this);
|
||||||
|
WebsiteSearchDialog = new WebsiteSearchDialog(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IWebDriver WebDriver { get; }
|
public IWebDriver WebDriver { get; }
|
||||||
|
|
||||||
public HarassCalculatorPage HarassCalculatorPage { get; }
|
public HarassCalculatorPage HarassCalculatorPage { get; }
|
||||||
|
public NavigationBar NavigationBar { get; }
|
||||||
|
public WebsiteSearchDialog WebsiteSearchDialog { get; }
|
||||||
|
|
||||||
public IWebElement Find(string byId) {
|
public IWebElement FindScreenSpecific(string byId)
|
||||||
return WebDriver.FindElement(By.Id(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 IList<IWebElement> FindChildren(string ofId, string tagname) {
|
|
||||||
|
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 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}"));
|
return WebDriver.FindElements(By.CssSelector($"#{ofId} {tagname}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string FindText(string byId) {
|
public string FindText(string byId)
|
||||||
|
{
|
||||||
return WebDriver.FindElement(By.Id(byId)).Text;
|
return WebDriver.FindElement(By.Id(byId)).Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int FindInt(string byId) {
|
public int FindInt(string byId)
|
||||||
|
{
|
||||||
return int.Parse(WebDriver.FindElement(By.Id(byId)).Text);
|
return int.Parse(WebDriver.FindElement(By.Id(byId)).Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IWebElement EnterInput<T>(IWebElement element, T input) {
|
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.Clear();
|
||||||
element.SendKeys(input!.ToString());
|
element.SendKeys(input!.ToString());
|
||||||
element.SendKeys(Keys.Enter);
|
element.SendKeys(Keys.Enter);
|
||||||
@@ -37,7 +115,8 @@ public class Website {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IWebElement EnterInput<T>(string byId, T input) {
|
public IWebElement EnterInput<T>(string byId, T input)
|
||||||
|
{
|
||||||
var element = Find(byId);
|
var element = Find(byId);
|
||||||
element.Clear();
|
element.Clear();
|
||||||
element.SendKeys(input!.ToString());
|
element.SendKeys(input!.ToString());
|
||||||
@@ -45,7 +124,8 @@ public class Website {
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetLabel(string byId) {
|
public string GetLabel(string byId)
|
||||||
|
{
|
||||||
return Find(byId).Text;
|
return Find(byId).Text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user