Files
Prowlarr-Prowlarr/src/NzbDrone.Automation.Test/PageModel/PageBase.cs
2025-06-09 22:08:00 +03:00

59 lines
1.6 KiB
C#

using System;
using System.Threading;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
namespace NzbDrone.Automation.Test.PageModel
{
public class PageBase
{
private readonly IWebDriver _driver;
public PageBase(IWebDriver driver)
{
_driver = driver;
}
public IWebElement FindByClass(string className, int timeout = 5)
{
return Find(By.ClassName(className), timeout);
}
public IWebElement Find(By by, int timeout = 5)
{
var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(timeout));
return wait.Until(d => d.FindElement(by));
}
public void WaitForNoSpinner(int timeout = 30)
{
//give the spinner some time to show up.
Thread.Sleep(200);
var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(timeout));
wait.Until(d =>
{
try
{
var element = d.FindElement(By.ClassName("followingBalls"));
return !element.Displayed;
}
catch (StaleElementReferenceException)
{
return true;
}
catch (NoSuchElementException)
{
return true;
}
});
}
public IWebElement MovieNavIcon => Find(By.LinkText("Indexers"));
public IWebElement SettingNavIcon => Find(By.LinkText("Settings"));
public IWebElement SystemNavIcon => Find(By.PartialLinkText("System"));
}
}