Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit 51dc81c

Browse files
authored
[UITestst] Add QueryUntilNotPresent (#13710)
1 parent cc0caa6 commit 51dc81c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3840.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void TranslatingViewKeepsScrollViewPosition()
9191
Assert.AreEqual(0, label[0].Rect.Height);
9292
Assert.AreEqual(0, label[0].Rect.Width);
9393
#else
94-
RunningApp.WaitForNoElement(_failedText);
94+
var result = RunningApp.QueryUntilNotPresent(() => RunningApp.Query(_failedText));
9595
#endif
9696
}
9797
#endif

Xamarin.Forms.Core.UITests.Shared/Utilities/AppExtensions.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,25 @@ public static T[] QueryUntilPresent<T>(
6868
return results;
6969
}
7070

71+
public static T[] QueryUntilNotPresent<T>(
72+
this IApp app,
73+
Func<T[]> func,
74+
int retryCount = 10,
75+
int delayInMs = 2000)
76+
{
77+
var results = func();
78+
79+
int counter = 0;
80+
while ((results != null || results.Length > 0) && counter < retryCount)
81+
{
82+
Thread.Sleep(delayInMs);
83+
results = func();
84+
counter++;
85+
}
86+
87+
return results;
88+
}
89+
7190
public static bool IsApiHigherThan(this IApp app, int apiLevel, string apiLabelId = "ApiLevel")
7291
{
7392
var api = Convert.ToInt32(app.WaitForElement("ApiLabel")[0].ReadText());

0 commit comments

Comments
 (0)