diff --git a/IGP/Pages/Database/Entity/Parts/EntityHeaderComponent.razor b/IGP/Pages/Database/Entity/Parts/EntityHeaderComponent.razor
index 6719ac0..cdeabb0 100644
--- a/IGP/Pages/Database/Entity/Parts/EntityHeaderComponent.razor
+++ b/IGP/Pages/Database/Entity/Parts/EntityHeaderComponent.razor
@@ -1,7 +1,7 @@
@if (StyleType.Equals("Plain"))
{
- @Entity?.Info().Name
+ @Entity?.Info().Name
@if (Entity?.Info().Descriptive != DescriptiveType.None)
{
, @Entity?.Info().Descriptive.Replace("_", " ")
@@ -11,7 +11,7 @@
else
{
@@ -91,7 +91,7 @@
-
+
diff --git a/TestAutomation/Pages/DatabasePage.cs b/TestAutomation/Pages/DatabasePage.cs
new file mode 100644
index 0000000..a761ea7
--- /dev/null
+++ b/TestAutomation/Pages/DatabasePage.cs
@@ -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
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;
+ }
+
+
+}
\ No newline at end of file
diff --git a/TestAutomation/Pages/DatabaseSinglePage.cs b/TestAutomation/Pages/DatabaseSinglePage.cs
index 1650e12..e21fe5e 100644
--- a/TestAutomation/Pages/DatabaseSinglePage.cs
+++ b/TestAutomation/Pages/DatabaseSinglePage.cs
@@ -5,7 +5,37 @@ namespace TestAutomation.Pages;
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 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;
+ }
+
}
\ No newline at end of file
diff --git a/TestAutomation/Shared/WebsiteSearchDialog.cs b/TestAutomation/Shared/WebsiteSearchDialog.cs
index ec78080..4458a2b 100644
--- a/TestAutomation/Shared/WebsiteSearchDialog.cs
+++ b/TestAutomation/Shared/WebsiteSearchDialog.cs
@@ -25,11 +25,9 @@ public class WebsiteSearchDialog : BaseElement
return this;
}
- public void SelectSearchEntity(string throne)
+ public DatabaseSinglePage SelectSearchEntity(string throne)
{
Website.Click(Website.FindButtonWithLabel(throne));
- //TODO Add DatabaseSinglePage
- //return Website.DatabaseSinglePage;
-
+ return Website.DatabaseSinglePage;
}
}
\ No newline at end of file
diff --git a/TestAutomation/TestSearchFeatures.cs b/TestAutomation/TestSearchFeatures.cs
index cdb5faf..c6de2f8 100644
--- a/TestAutomation/TestSearchFeatures.cs
+++ b/TestAutomation/TestSearchFeatures.cs
@@ -1,3 +1,5 @@
+using TestAutomation.Utils;
+
namespace TestAutomation;
[TestFixture]
@@ -17,7 +19,6 @@ public class TestSearchFeatures : BaseTest
}
[Test]
- [Ignore("Not completed")]
public void DesktopSearchForThrone()
{
TestReport.CreateTest();
@@ -27,9 +28,59 @@ public class TestSearchFeatures : BaseTest
Website.NavigationBar
.ClickSearchButton()
.Search("Throne")
- .SelectSearchEntity("Throne");
- // .GetName(out var name);
+ .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()
+ {
+ 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."});
- // TestReport.CheckPassed(name.Equals("Throne"), "Couldn't find Throne via search.");
+ Website.WebDriver.Navigate().GoToUrl(WebsiteUrl + "/database/not throne");
}
}
\ No newline at end of file
diff --git a/TestAutomation/Utils/Website.cs b/TestAutomation/Utils/Website.cs
index 37fbf0a..9a9ca31 100644
--- a/TestAutomation/Utils/Website.cs
+++ b/TestAutomation/Utils/Website.cs
@@ -1,4 +1,5 @@
-using OpenQA.Selenium.Interactions;
+using System.Collections.ObjectModel;
+using OpenQA.Selenium.Interactions;
using TestAutomation.Enums;
using TestAutomation.Shared;
@@ -12,14 +13,23 @@ public class Website
{
WebDriver = webDriver;
+ // Pages
HarassCalculatorPage = new HarassCalculatorPage(this);
+ DatabasePage = new DatabasePage(this);
+ DatabaseSinglePage = new DatabaseSinglePage(this);
+
+ // Navigation
NavigationBar = new NavigationBar(this);
+
+ // Dialogs
WebsiteSearchDialog = new WebsiteSearchDialog(this);
}
public IWebDriver WebDriver { get; }
public HarassCalculatorPage HarassCalculatorPage { get; }
+ public DatabaseSinglePage DatabaseSinglePage { get; }
+ public DatabasePage DatabasePage { get; }
public NavigationBar NavigationBar { 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)
{
try
@@ -52,11 +87,25 @@ public class Website
}
}
+ public ReadOnlyCollection 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)
{
try
{
- return WebDriver.FindElement(By.XPath($"button[@label='{label}']"));
+ return WebDriver.FindElement(By.XPath($"//button[@label='{label}']"));
}
catch (Exception e)
{
diff --git a/TestAutomation/Tests.cs b/TestAutomation/_Tests.cs
similarity index 100%
rename from TestAutomation/Tests.cs
rename to TestAutomation/_Tests.cs