test(BrokenLinks) Now checking for broken links on a few pages
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
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,10 +1,9 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using TestAutomation.Shared;
|
||||
using TestAutomation.Utils;
|
||||
|
||||
namespace TestAutomation.Pages;
|
||||
|
||||
public class DatabasePage : BaseElement
|
||||
public class DatabasePage : BasePage
|
||||
{
|
||||
public DatabasePage(Website website) : base(website)
|
||||
{
|
||||
@@ -12,6 +11,8 @@ public class DatabasePage : BaseElement
|
||||
|
||||
private IWebElement FilterNameInput => Website.Find("filterName");
|
||||
|
||||
public override string Url { get; set; } = "database";
|
||||
|
||||
|
||||
private ReadOnlyCollection<IWebElement> EntityNames()
|
||||
{
|
||||
@@ -43,4 +44,10 @@ public class DatabasePage : BaseElement
|
||||
result = EntityNames()[index].Text;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DatabasePage Goto()
|
||||
{
|
||||
Website.Goto(Url);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
using TestAutomation.Shared;
|
||||
using TestAutomation.Utils;
|
||||
using TestAutomation.Utils;
|
||||
|
||||
namespace TestAutomation.Pages;
|
||||
|
||||
public class DatabaseSinglePage : BaseElement
|
||||
public class DatabaseSinglePage : BasePage
|
||||
{
|
||||
public DatabaseSinglePage(Website website) : base(website)
|
||||
{
|
||||
@@ -15,6 +14,8 @@ public class DatabaseSinglePage : BaseElement
|
||||
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)
|
||||
{
|
||||
@@ -39,4 +40,10 @@ public class DatabaseSinglePage : BaseElement
|
||||
result = ValidSearch.Text;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DatabaseSinglePage Goto(string searchText)
|
||||
{
|
||||
Website.Goto($"{Url}/{searchText}");
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
using TestAutomation.Shared;
|
||||
using TestAutomation.Utils;
|
||||
using TestAutomation.Utils;
|
||||
|
||||
namespace TestAutomation.Pages;
|
||||
|
||||
public class HarassCalculatorPage : BaseElement
|
||||
public class HarassCalculatorPage : BasePage
|
||||
{
|
||||
public HarassCalculatorPage(Website website) : base(website)
|
||||
{
|
||||
@@ -24,6 +23,8 @@ public class HarassCalculatorPage : BaseElement
|
||||
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);
|
||||
@@ -84,4 +85,15 @@ public class HarassCalculatorPage : BaseElement
|
||||
result = ExampleTotalAlloyLossAccurateDifference;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected HarassCalculatorPage NavigateTo()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public HarassCalculatorPage Goto()
|
||||
{
|
||||
Website.Goto(Url);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user