diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3840.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3840.cs index a68d229ed70..5964849ff18 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3840.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3840.cs @@ -91,7 +91,7 @@ public void TranslatingViewKeepsScrollViewPosition() Assert.AreEqual(0, label[0].Rect.Height); Assert.AreEqual(0, label[0].Rect.Width); #else - RunningApp.WaitForNoElement(_failedText); + var result = RunningApp.QueryUntilNotPresent(() => RunningApp.Query(_failedText)); #endif } #endif diff --git a/Xamarin.Forms.Core.UITests.Shared/Utilities/AppExtensions.cs b/Xamarin.Forms.Core.UITests.Shared/Utilities/AppExtensions.cs index a8488d26cfb..f4f627daed1 100644 --- a/Xamarin.Forms.Core.UITests.Shared/Utilities/AppExtensions.cs +++ b/Xamarin.Forms.Core.UITests.Shared/Utilities/AppExtensions.cs @@ -68,6 +68,25 @@ public static T[] QueryUntilPresent( return results; } + public static T[] QueryUntilNotPresent( + this IApp app, + Func func, + int retryCount = 10, + int delayInMs = 2000) + { + var results = func(); + + int counter = 0; + while ((results != null || results.Length > 0) && counter < retryCount) + { + Thread.Sleep(delayInMs); + results = func(); + counter++; + } + + return results; + } + public static bool IsApiHigherThan(this IApp app, int apiLevel, string apiLabelId = "ApiLevel") { var api = Convert.ToInt32(app.WaitForElement("ApiLabel")[0].ReadText());