Merge pull request #27 from JonathanMcCaffrey/5-add-complex-search-tests
5 add complex search tests
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
@onclick:stopPropagation="true">
|
@onclick:stopPropagation="true">
|
||||||
|
|
||||||
<FormLayoutComponent>
|
<FormLayoutComponent>
|
||||||
<FormTextComponent OnFocus="OnFocus" Id="search-input-box" Placeholder="Search..." OnInput="SearchChanged"></FormTextComponent>
|
<FormTextComponent OnFocus="OnFocus" Id="searchInput" Placeholder="Search..." OnInput="SearchChanged"></FormTextComponent>
|
||||||
</FormLayoutComponent>
|
</FormLayoutComponent>
|
||||||
|
|
||||||
<div class="searchBox">
|
<div class="searchBox">
|
||||||
@@ -134,7 +134,7 @@
|
|||||||
|
|
||||||
private void FocusTimer(object? sender, ElapsedEventArgs e)
|
private void FocusTimer(object? sender, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
jsRuntime.InvokeVoidAsync("SetFocusToElement", "search-input-box");
|
jsRuntime.InvokeVoidAsync("SetFocusToElement", "searchInput");
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,8 @@
|
|||||||
else if (_entity == null)
|
else if (_entity == null)
|
||||||
{
|
{
|
||||||
<PaperComponent>
|
<PaperComponent>
|
||||||
<div>Invalid entity name entered: @Text</div>
|
<div>Invalid entity name entered: <span id="invalidSearch">@Text</span></div>
|
||||||
<div>No such entity. Did you mean <b>"Throne"</b>?</div>
|
<div>No such entity. Did you mean <b>"<span id="validSearch">Throne</span>"</b>?</div>
|
||||||
</PaperComponent>
|
</PaperComponent>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
var isVanguard = Entity.VanguardAdded() != null ? " vanguard" : "";
|
var isVanguard = Entity.VanguardAdded() != null ? " vanguard" : "";
|
||||||
|
|
||||||
<div class="entitiesContainer @isVanguard">
|
<div id="@Entity.EntityType.ToLower()-@Entity.Info().Name.ToLower()" class="entitiesContainer @isVanguard">
|
||||||
<EntityHeaderComponent></EntityHeaderComponent>
|
<EntityHeaderComponent></EntityHeaderComponent>
|
||||||
<div class="entityPartsContainer">
|
<div class="entityPartsContainer">
|
||||||
<EntityVanguardAddedComponent></EntityVanguardAddedComponent>
|
<EntityVanguardAddedComponent></EntityVanguardAddedComponent>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
@if (StyleType.Equals("Plain"))
|
@if (StyleType.Equals("Plain"))
|
||||||
{
|
{
|
||||||
<div>
|
<div>
|
||||||
<b>@Entity?.Info().Name</b>
|
<b id="entityName">@Entity?.Info().Name</b>
|
||||||
@if (Entity?.Info().Descriptive != DescriptiveType.None)
|
@if (Entity?.Info().Descriptive != DescriptiveType.None)
|
||||||
{
|
{
|
||||||
<span>, @Entity?.Info().Descriptive.Replace("_", " ")</span>
|
<span>, @Entity?.Info().Descriptive.Replace("_", " ")</span>
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
<div class="entityHeader">
|
<div class="entityHeader">
|
||||||
<div class="entityHeaderText">
|
<div id="entityName" class="entityHeaderText">
|
||||||
@Entity?.Info().Name
|
@Entity?.Info().Name
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size:1.4rem;">
|
<div style="font-size:1.4rem;">
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
@if (!Vitality.Health.Equals(0))
|
@if (!Vitality.Health.Equals(0))
|
||||||
{
|
{
|
||||||
<div>
|
<div>
|
||||||
<b>Health:</b> @Vitality.Health
|
<b>Health:</b> <span id="entityHealth">@Vitality.Health</span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@if (!Vitality.Energy.Equals(0))
|
@if (!Vitality.Energy.Equals(0))
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
@if (!Vitality.Health.Equals(0))
|
@if (!Vitality.Health.Equals(0))
|
||||||
{
|
{
|
||||||
<div>
|
<div>
|
||||||
<b>Health:</b> @Vitality.Health
|
<b>Health:</b> <span id="entityHealth">@Vitality.Health</span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@if (!Vitality.Energy.Equals(0))
|
@if (!Vitality.Energy.Equals(0))
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
<button class="choiceButton @styleClass" @onclick="@(e => OnChangeEntity(choice))">@choice.Replace("_", " ")</button>
|
<button class="choiceButton @styleClass" @onclick="@(e => OnChangeEntity(choice))">@choice.Replace("_", " ")</button>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<FormTextComponent Label="Search Label" Placeholder="Throne..." OnChange="@(e => EntityFilterService.EnterSearchText(e.Value!.ToString()!))"/>
|
<FormTextComponent Id="filterName" Label="Filter Name" Placeholder="Throne..." OnChange="@(e => EntityFilterService.EnterSearchText(e.Value!.ToString()!))"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
</FormSelectComponent>
|
</FormSelectComponent>
|
||||||
|
|
||||||
|
|
||||||
<FormTextComponent Label="Search Label" Placeholder="Throne..." OnChange="OnSearchTextChanged"/>
|
<FormTextComponent Id="filterName" Label="Filter Name" Placeholder="Throne..." OnChange="OnSearchTextChanged"/>
|
||||||
</FormLayoutComponent>
|
</FormLayoutComponent>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using TestAutomation.Shared;
|
||||||
|
using TestAutomation.Utils;
|
||||||
|
|
||||||
|
namespace TestAutomation.Pages;
|
||||||
|
|
||||||
|
public class DatabasePage : BaseElement
|
||||||
|
{
|
||||||
|
|
||||||
|
private IWebElement FilterNameInput => Website.Find("filterName");
|
||||||
|
|
||||||
|
|
||||||
|
private ReadOnlyCollection<IWebElement> EntityNames() =>
|
||||||
|
Website.FindAll("entityName");
|
||||||
|
|
||||||
|
|
||||||
|
private IWebElement EntityName(string entityType, string entityName) =>
|
||||||
|
Website.Find("entityName",
|
||||||
|
$"{entityType.ToLower()}-{entityName.ToLower()}");
|
||||||
|
|
||||||
|
|
||||||
|
public DatabasePage(Website website) : base(website) { }
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,7 +5,37 @@ namespace TestAutomation.Pages;
|
|||||||
|
|
||||||
public class DatabaseSinglePage : BaseElement
|
public class DatabaseSinglePage : BaseElement
|
||||||
{
|
{
|
||||||
|
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 DatabaseSinglePage(Website website) : base(website) { }
|
public DatabaseSinglePage(Website website) : base(website) { }
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,11 +25,9 @@ public class WebsiteSearchDialog : BaseElement
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectSearchEntity(string throne)
|
public DatabaseSinglePage SelectSearchEntity(string throne)
|
||||||
{
|
{
|
||||||
Website.Click(Website.FindButtonWithLabel(throne));
|
Website.Click(Website.FindButtonWithLabel(throne));
|
||||||
//TODO Add DatabaseSinglePage
|
return Website.DatabaseSinglePage;
|
||||||
//return Website.DatabaseSinglePage;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using TestAutomation.Utils;
|
||||||
|
|
||||||
namespace TestAutomation;
|
namespace TestAutomation;
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
@@ -17,7 +19,6 @@ public class TestSearchFeatures : BaseTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[Ignore("Not completed")]
|
|
||||||
public void DesktopSearchForThrone()
|
public void DesktopSearchForThrone()
|
||||||
{
|
{
|
||||||
TestReport.CreateTest();
|
TestReport.CreateTest();
|
||||||
@@ -27,9 +28,59 @@ public class TestSearchFeatures : BaseTest
|
|||||||
Website.NavigationBar
|
Website.NavigationBar
|
||||||
.ClickSearchButton()
|
.ClickSearchButton()
|
||||||
.Search("Throne")
|
.Search("Throne")
|
||||||
.SelectSearchEntity("Throne");
|
.SelectSearchEntity("Throne")
|
||||||
// .GetName(out var name);
|
.GetEntityName(out var name)
|
||||||
|
.GetEntityHealth(out var health);
|
||||||
|
|
||||||
// TestReport.CheckPassed(name.Equals("Throne"), "Couldn't find Throne via search.");
|
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()
|
||||||
|
{
|
||||||
|
TestReport.CreateTest();
|
||||||
|
|
||||||
|
Website.WebDriver.Navigate().GoToUrl(WebsiteUrl + "/database");
|
||||||
|
|
||||||
|
Website.DatabasePage
|
||||||
|
.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()
|
||||||
|
{
|
||||||
|
TestReport.CreateTest();
|
||||||
|
|
||||||
|
Website.WebDriver.Navigate().GoToUrl(WebsiteUrl + "/database");
|
||||||
|
|
||||||
|
Website.DatabasePage
|
||||||
|
.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()
|
||||||
|
{
|
||||||
|
TestReport.CreateTest();
|
||||||
|
|
||||||
|
Website.WebDriver.Navigate().GoToUrl(WebsiteUrl + "/database/not throne");
|
||||||
|
|
||||||
|
Website.DatabaseSinglePage
|
||||||
|
.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."});
|
||||||
|
|
||||||
|
Website.WebDriver.Navigate().GoToUrl(WebsiteUrl + "/database/not throne");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using OpenQA.Selenium.Interactions;
|
using System.Collections.ObjectModel;
|
||||||
|
using OpenQA.Selenium.Interactions;
|
||||||
using TestAutomation.Enums;
|
using TestAutomation.Enums;
|
||||||
using TestAutomation.Shared;
|
using TestAutomation.Shared;
|
||||||
|
|
||||||
@@ -12,14 +13,23 @@ public class Website
|
|||||||
{
|
{
|
||||||
WebDriver = webDriver;
|
WebDriver = webDriver;
|
||||||
|
|
||||||
|
// Pages
|
||||||
HarassCalculatorPage = new HarassCalculatorPage(this);
|
HarassCalculatorPage = new HarassCalculatorPage(this);
|
||||||
|
DatabasePage = new DatabasePage(this);
|
||||||
|
DatabaseSinglePage = new DatabaseSinglePage(this);
|
||||||
|
|
||||||
|
// Navigation
|
||||||
NavigationBar = new NavigationBar(this);
|
NavigationBar = new NavigationBar(this);
|
||||||
|
|
||||||
|
// Dialogs
|
||||||
WebsiteSearchDialog = new WebsiteSearchDialog(this);
|
WebsiteSearchDialog = new WebsiteSearchDialog(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IWebDriver WebDriver { get; }
|
public IWebDriver WebDriver { get; }
|
||||||
|
|
||||||
public HarassCalculatorPage HarassCalculatorPage { get; }
|
public HarassCalculatorPage HarassCalculatorPage { get; }
|
||||||
|
public DatabaseSinglePage DatabaseSinglePage { get; }
|
||||||
|
public DatabasePage DatabasePage { get; }
|
||||||
public NavigationBar NavigationBar { get; }
|
public NavigationBar NavigationBar { get; }
|
||||||
public WebsiteSearchDialog WebsiteSearchDialog { get; }
|
public WebsiteSearchDialog WebsiteSearchDialog { get; }
|
||||||
|
|
||||||
@@ -39,6 +49,31 @@ public class Website
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
public IWebElement Find(string byId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -52,11 +87,25 @@ public class Website
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 IWebElement FindButtonWithLabel(string label)
|
public IWebElement FindButtonWithLabel(string label)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return WebDriver.FindElement(By.XPath($"button[@label='{label}']"));
|
return WebDriver.FindElement(By.XPath($"//button[@label='{label}']"));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user