-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathBasePage.cs
41 lines (35 loc) · 1.44 KB
/
BasePage.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using NUnit.Framework;
using Xamarin.UITest;
namespace Xamarin.UITest.SpecFlow
{
public abstract class BasePage
{
protected IApp app => AppManager.App;
protected bool OnAndroid => AppManager.Platform == Platform.Android;
protected bool OniOS => AppManager.Platform == Platform.iOS;
protected abstract PlatformQuery Trait { get; }
protected BasePage()
{
}
/// <summary>
/// Verifies that the trait is present. Uses the default wait time.
/// </summary>
/// <param name="timeout">Time to wait before the assertion fails</param>
public void AssertOnPage(TimeSpan? timeout = default(TimeSpan?))
{
var message = "Unable to verify on page: " + this.GetType().Name;
Assert.DoesNotThrow(() => app.WaitForElement(Trait.Current, timeout: timeout), message);
}
/// <summary>
/// Verifies that the trait is no longer present. Defaults to a 5 second wait.
/// </summary>
/// <param name="timeout">Time to wait before the assertion fails</param>
public void WaitForPageToLeave(TimeSpan? timeout = default(TimeSpan?))
{
timeout = timeout ?? TimeSpan.FromSeconds(5);
var message = "Unable to verify *not* on page: " + this.GetType().Name;
Assert.DoesNotThrow(() => app.WaitForNoElement(Trait.Current, timeout: timeout), message);
}
}
}