25 lines
651 B
C#
25 lines
651 B
C#
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, StringComparison.OrdinalIgnoreCase));
|
|
|
|
if (link == null) throw new NoSuchElementException($"Link with text '{linkText}' not found in the page.");
|
|
|
|
link.Click();
|
|
}
|
|
} |