-
Netrom authorede4f1d9ed
using OpenQA.Selenium;
using System.Threading;
using Xunit;
using Xunit.Gherkin.Quick;
using Memri.Tests.iOSUiFramework;
using Unity;
using Memri.Tests.DI;
namespace Memri.Tests.Tests
{
[FeatureFile("./Features/CheckNavigationToPerson.feature"), Collection("Sequential")]
public class CheckNavigationToPerson : Feature
{
protected iOSBrowser iOSBrowser { get; }
private readonly IUnityContainer _container = IoC.Container.CreateChildContainer();
public CheckNavigationToPerson()
{
iOSBrowser = Resolve<iOSBrowser>("DefaultBrowser");
Thread.Sleep(1000);
}
protected T Resolve<T>(string name = null)
{
return name == null ? _container.Resolve<T>() : _container.Resolve<T>(name);
}
[Given("The user is on the All notes page")]
public void GivenTheUserIsOnTheAllNotesPage()
{
var allNotes = iOSBrowser.FindElement(By.XPath("//XCUIElementTypeButton[@name='All Notes']"));
Assert.Equal("All Notes", allNotes.Text);
}
[When("Clicking on the hamburger button")]
public void WhenClickingOnTheHamburgerButton()
{
iOSBrowser.FindElement(By.XPath("//XCUIElementTypeButton[@name='line.horizontal.3']")).Click();
}
[And(@"Clicking on? (.*)$")]
public void AndClickingOnPeople(string people)
{
iOSBrowser.FindElement(By.XPath($@"//XCUIElementTypeButton[@name='{people.Replace("\"", "")}']")).Click();
}
[And(@"Then clicking on? (.*)$")]
public void AndThenClickingOn(string name)
{
iOSBrowser.FindElement(By.XPath($@"//XCUIElementTypeStaticText[@name='{name.Replace("\"", "")}']")).Click();
}
[Then(@"^The user is on the detail page of? (.*)$")]
public void ThenTheUserIsOnTheDetailPageOf(string name)
{
var person = iOSBrowser.FindElement(By.XPath($@"//XCUIElementTypeButton[@name='{name.Replace("\"", "")}']"));
Assert.Equal(name, person.Text);
iOSBrowser.FindElement(By.XPath("//XCUIElementTypeButton[@name='line.horizontal.3']")).Click();
iOSBrowser.FindElement(By.XPath("//XCUIElementTypeButton[@name='Notes'][1]")).Click();
}
}
}