summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.iOS.UITests/Utilities/AppExtensions.cs
blob: b5f52b9cc4a9d71e9aef6a673b71528fafed956b (plain)
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
´╗┐using System;
using System.Linq;

using Xamarin.UITest;
using Xamarin.UITest.Queries;
using System.Text.RegularExpressions;

namespace Xamarin.Forms.Core.UITests
{
	internal static class AppExtensions
	{
		public static AppRect ScreenBounds (this IApp app)
		{
			return app.Query (Queries.Root ()).First().Rect;
		}

		public static void NavigateBack (this IApp app)
		{
			app.Tap (Queries.NavigationBarBackButton ());
		}

		public static void NavigateToGallery (this IApp app, string page)
		{
			const string goToTestButtonQuery = "* marked:'GoToTestButton'";

			var text = Regex.Match (page, "'(?<text>[^']*)'").Groups["text"].Value;
			app.EnterText (q => q.Raw ("* marked:'SearchBar'"), text);
			
			app.WaitForElement(q => q.Raw(goToTestButtonQuery), "Timed out waiting for Go To Test button to disappear", TimeSpan.FromSeconds(10));

			app.Tap (q => q.Raw (goToTestButtonQuery));
			app.WaitForNoElement (o => o.Raw (goToTestButtonQuery), "Timed out waiting for Go To Test button to disappear", TimeSpan.FromMinutes(2));
		}
	}
}