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

[UITestst] Add QueryUntilNotPresent #13710

Merged
merged 1 commit into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions Xamarin.Forms.Core.UITests.Shared/Utilities/AppExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,25 @@ public static T[] QueryUntilPresent<T>(
return results;
}

public static T[] QueryUntilNotPresent<T>(
this IApp app,
Func<T[]> 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());
Expand Down