You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/src/NzbDrone.Automation.Test/PageModel/PageBase.cs

101 lines
2.3 KiB

using System;
using System.Threading;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.UI;
namespace NzbDrone.Automation.Test.PageModel
{
public class PageBase
{
private readonly RemoteWebDriver _driver;
public PageBase(RemoteWebDriver driver)
{
_driver = driver;
driver.Manage().Window.Maximize();
}
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 = 20)
{
//give the spinner some time to show up.
Thread.Sleep(100);
var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(timeout));
wait.Until(d =>
{
try
{
IWebElement element = d.FindElement(By.Id("followingBalls"));
return !element.Displayed;
}
catch (NoSuchElementException)
{
return true;
}
});
}
public IWebElement SeriesNavIcon
{
get
{
return FindByClass("x-series-nav");
}
}
public IWebElement CalendarNavIcon
{
get
{
return FindByClass("x-calendar-nav");
}
}
public IWebElement HistoryNavIcon
{
get
{
return FindByClass("x-history-nav");
}
}
public IWebElement WantedNavIcon
{
get
{
return FindByClass("x-wanted-nav");
}
}
public IWebElement SettingNavIcon
{
get
{
return FindByClass("x-settings-nav");
}
}
public IWebElement SystemNavIcon
{
get
{
return FindByClass("x-system-nav");
}
}
}
}