summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2016-11-19 12:34:35 -0700
committerGitHub <noreply@github.com>2016-11-19 12:34:35 -0700
commit33a5f443d31a250b9b956f9039daeea67faf6555 (patch)
tree6e81bae0d5c1a38d2881d19d6b48ff6eea95537d /Xamarin.Forms.Controls.Issues
parentaf29ab93b9980677bd03ea414262c327f85042f7 (diff)
downloadxamarin-forms-33a5f443d31a250b9b956f9039daeea67faf6555.tar.gz
xamarin-forms-33a5f443d31a250b9b956f9039daeea67faf6555.tar.bz2
xamarin-forms-33a5f443d31a250b9b956f9039daeea67faf6555.zip
Adding some restart logic to the UI tests if navigation fails (#550)
Diffstat (limited to 'Xamarin.Forms.Controls.Issues')
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/TestPages/TestPages.cs73
1 files changed, 55 insertions, 18 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/TestPages/TestPages.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/TestPages/TestPages.cs
index 0439c791..32a88642 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/TestPages/TestPages.cs
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/TestPages/TestPages.cs
@@ -82,15 +82,22 @@ namespace Xamarin.Forms.Controls
cellName = typeIssueAttribute.Description;
}
- try
+ int maxAttempts = 2;
+ int attempts = 0;
+
+ while (attempts < maxAttempts)
{
- // Attempt the direct way of navigating to the test page
-#if __ANDROID__
+ attempts += 1;
- if (bool.Parse((string)app.Invoke("NavigateToTest", cellName)))
+ try
{
- return;
- }
+ // Attempt the direct way of navigating to the test page
+#if __ANDROID__
+
+ if (bool.Parse((string)app.Invoke("NavigateToTest", cellName)))
+ {
+ return;
+ }
#endif
#if __IOS__
if (bool.Parse(app.Invoke("navigateToTest:", cellName).ToString()))
@@ -98,20 +105,50 @@ namespace Xamarin.Forms.Controls
return;
}
#endif
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine($"Could not directly invoke test, using UI navigation. {ex}");
- }
-
- // Fall back to the "manual" navigation method
- app.Tap (q => q.Button ("Go to Test Cases"));
- app.WaitForElement (q => q.Raw ("* marked:'TestCasesIssueList'"));
+ }
+ catch (Exception ex)
+ {
+ var debugMessage = $"Could not directly invoke test; using UI navigation instead. {ex}";
+
+ System.Diagnostics.Debug.WriteLine(debugMessage);
+ Console.WriteLine(debugMessage);
+ }
+
+ try
+ {
+ // Fall back to the "manual" navigation method
+ app.Tap(q => q.Button("Go to Test Cases"));
+ app.WaitForElement(q => q.Raw("* marked:'TestCasesIssueList'"));
+
+ app.EnterText(q => q.Raw("* marked:'SearchBarGo'"), cellName);
- app.EnterText (q => q.Raw ("* marked:'SearchBarGo'"), cellName);
+ app.WaitForElement(q => q.Raw("* marked:'SearchButton'"));
+ app.Tap(q => q.Raw("* marked:'SearchButton'"));
- app.WaitForElement (q => q.Raw ("* marked:'SearchButton'"));
- app.Tap (q => q.Raw ("* marked:'SearchButton'"));
+ return;
+ }
+ catch (Exception ex)
+ {
+ var debugMessage = $"Both navigation methods failed. {ex}";
+
+ System.Diagnostics.Debug.WriteLine(debugMessage);
+ Console.WriteLine(debugMessage);
+
+ if (attempts < maxAttempts)
+ {
+ // Something has failed and we're stuck in a place where we can't navigate
+ // to the test. Usually this is because we're getting network/HTTP errors
+ // communicating with the server on the device. So we'll try restarting the app.
+ RunningApp = InitializeApp();
+ }
+ else
+ {
+ // But if it's still not working after [maxAttempts], we've got assume this is a legit
+ // problem that restarting won't fix
+ throw;
+ }
+ }
+ }
}
public static IApp Setup (Type pageType = null)