Code cleanup
This commit is contained in:
@@ -5,11 +5,15 @@ namespace AOW4.SeleniumTests.Pages;
|
||||
public class CounterPage
|
||||
{
|
||||
private readonly IWebDriver _driver;
|
||||
public CounterPage(IWebDriver driver) => _driver = 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");
|
||||
return url.Contains("counter", StringComparison.OrdinalIgnoreCase) || _driver.PageSource.Contains("Counter");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,16 @@ namespace AOW4.SeleniumTests.Pages;
|
||||
public class HomePage
|
||||
{
|
||||
private readonly IWebDriver _driver;
|
||||
public HomePage(IWebDriver driver) => _driver = 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");
|
||||
return url.EndsWith("/") || url.Contains("/index", StringComparison.OrdinalIgnoreCase) ||
|
||||
_driver.PageSource.Contains("Home");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Linq;
|
||||
using OpenQA.Selenium;
|
||||
|
||||
namespace AOW4.SeleniumTests.Pages;
|
||||
@@ -15,13 +14,12 @@ public class NavMenuPage
|
||||
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));
|
||||
.FirstOrDefault(e =>
|
||||
!string.IsNullOrWhiteSpace(e.Text) &&
|
||||
e.Text.Trim().Equals(linkText, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (link == null)
|
||||
{
|
||||
throw new NoSuchElementException($"Link with text '{linkText}' not found in the page.");
|
||||
}
|
||||
if (link == null) throw new NoSuchElementException($"Link with text '{linkText}' not found in the page.");
|
||||
|
||||
link.Click();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
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