Stub Gen Selenium Tests
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using OpenQA.Selenium;
|
||||
|
||||
namespace AOW4.SeleniumTests.Pages;
|
||||
|
||||
public class CounterPage
|
||||
{
|
||||
private readonly IWebDriver _driver;
|
||||
public CounterPage(IWebDriver driver) => _driver = driver;
|
||||
|
||||
public bool IsAt()
|
||||
{
|
||||
var url = _driver.Url ?? string.Empty;
|
||||
return url.Contains("counter", System.StringComparison.OrdinalIgnoreCase) || _driver.PageSource.Contains("Counter");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using OpenQA.Selenium;
|
||||
|
||||
namespace AOW4.SeleniumTests.Pages;
|
||||
|
||||
public class HomePage
|
||||
{
|
||||
private readonly IWebDriver _driver;
|
||||
public HomePage(IWebDriver driver) => _driver = driver;
|
||||
|
||||
public bool IsAt()
|
||||
{
|
||||
var url = _driver.Url ?? string.Empty;
|
||||
return url.EndsWith("/") || url.Contains("/index", System.StringComparison.OrdinalIgnoreCase) || _driver.PageSource.Contains("Home");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Linq;
|
||||
using OpenQA.Selenium;
|
||||
|
||||
namespace AOW4.SeleniumTests.Pages;
|
||||
|
||||
public class NavMenuPage
|
||||
{
|
||||
private readonly IWebDriver _driver;
|
||||
|
||||
public NavMenuPage(IWebDriver driver)
|
||||
{
|
||||
_driver = driver;
|
||||
}
|
||||
|
||||
public void ClickLinkByText(string linkText)
|
||||
{
|
||||
var link = _driver.FindElements(By.CssSelector("a[href]"))
|
||||
.FirstOrDefault(e => !string.IsNullOrWhiteSpace(e.Text) && e.Text.Trim().Equals(linkText, System.StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (link == null)
|
||||
{
|
||||
throw new NoSuchElementException($"Link with text '{linkText}' not found in the page.");
|
||||
}
|
||||
|
||||
link.Click();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using OpenQA.Selenium;
|
||||
|
||||
namespace AOW4.SeleniumTests.Pages;
|
||||
|
||||
public class WeatherPage
|
||||
{
|
||||
private readonly IWebDriver _driver;
|
||||
public WeatherPage(IWebDriver driver) => _driver = driver;
|
||||
|
||||
public bool IsAt()
|
||||
{
|
||||
var url = _driver.Url ?? string.Empty;
|
||||
return url.Contains("weather", System.StringComparison.OrdinalIgnoreCase) || _driver.PageSource.Contains("Weather");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user