1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

new add series page automation

PageBase helper class.
This commit is contained in:
kayone 2013-11-17 19:34:31 -08:00
parent ff0785b8d1
commit b29b560b14
4 changed files with 150 additions and 15 deletions

View File

@ -7,6 +7,7 @@
using NLog.Config;
using NLog.Targets;
using NUnit.Framework;
using NzbDrone.Automation.Test.PageModel;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Test.Common;
using OpenQA.Selenium;
@ -46,9 +47,8 @@ public void SmokeTestSetup()
driver.Url = "http://localhost:8989";
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until(d => d.FindElement(By.Id("x-toolbar")));
var page = new PageBase(driver);
page.WaitForNoSpinner();
GetPageErrors().Should().BeEmpty();
@ -70,7 +70,6 @@ public void SmokeTestTearDown()
[TearDown]
public void AutomationTearDown()
{
Thread.Sleep(2000);
GetPageErrors().Should().BeEmpty();
}
}

View File

@ -1,44 +1,79 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Automation.Test.PageModel;
using OpenQA.Selenium;
namespace NzbDrone.Automation.Test
{
[TestFixture]
public class MainPagesTest : AutomationTest
{
private PageBase page;
[SetUp]
public void Setup()
{
page = new PageBase(driver);
}
[Test]
public void series_page()
{
driver.FindElementByLinkText("Series").Click();
driver.FindElementByClassName("iv-series-index-seriesindexlayout").Should().NotBeNull();
page.SeriesNavIcon.Click();
page.WaitForNoSpinner();
page.FindByClass("iv-series-index-seriesindexlayout").Should().NotBeNull();
}
[Test]
public void calendar_page()
{
driver.FindElementByLinkText("Calendar").Click();
driver.FindElementByClassName("iv-calendar-calendarlayout").Should().NotBeNull();
page.CalendarNavIcon.Click();
page.WaitForNoSpinner();
page.FindByClass("iv-calendar-calendarlayout").Should().NotBeNull();
}
[Test]
public void history_page()
{
driver.FindElementByLinkText("History").Click();
driver.FindElementByClassName("iv-history-historylayout").Should().NotBeNull();
page.HistoryNavIcon.Click();
page.WaitForNoSpinner();
page.FindByClass("iv-history-historylayout").Should().NotBeNull();
}
[Test]
public void missing_page()
{
driver.FindElementByLinkText("Settings").Click();
page.MissingNavIcon.Click();
page.WaitForNoSpinner();
page.FindByClass("iv-missing-missinglayout").Should().NotBeNull();
}
[Test]
public void system_page()
{
driver.FindElementByLinkText("System").Click();
driver.FindElementByClassName("iv-system-systemlayout").Should().NotBeNull();
page.SystemNavIcon.Click();
page.WaitForNoSpinner();
page.FindByClass("iv-system-systemlayout").Should().NotBeNull();
}
[Test]
public void add_series_page()
{
page.SeriesNavIcon.Click();
page.WaitForNoSpinner();
page.Find(By.LinkText("Add Series")).Click();
page.WaitForNoSpinner();
page.FindByClass("iv-addseries-addserieslayout").Should().NotBeNull();
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -62,6 +62,7 @@
<Compile Include="AutomationTestAttribute.cs" />
<Compile Include="AutomationTest.cs" />
<Compile Include="MainPagesTest.cs" />
<Compile Include="PageModel\PageBase.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>

View File

@ -0,0 +1,100 @@
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;
}
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 Find(By.LinkText("Series"));
}
}
public IWebElement CalendarNavIcon
{
get
{
return Find(By.LinkText("Calendar"));
}
}
public IWebElement HistoryNavIcon
{
get
{
return Find(By.LinkText("History"));
}
}
public IWebElement MissingNavIcon
{
get
{
return Find(By.LinkText("Missing"));
}
}
public IWebElement SettingNavIcon
{
get
{
return Find(By.LinkText("Settings"));
}
}
public IWebElement SystemNavIcon
{
get
{
return Find(By.LinkText("System"));
}
}
}
}