-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Testing] Fix for flaky UITests in CI - 4 #33215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -361,13 +361,24 @@ public void DropEventCoordinates() | |
|
|
||
| App.WaitForElement("Blue"); | ||
| App.WaitForElement("Green"); | ||
| App.DragAndDrop("Blue", "Green"); | ||
|
|
||
| // Wait for all UI elements to confirm drag and drop operation completion | ||
| App.WaitForElement("DropRelativeLayout"); | ||
| App.WaitForElement("DropRelativeScreen"); | ||
| App.WaitForElement("DropRelativeLabel"); | ||
| App.WaitForElement("DragStartRelativeScreen"); | ||
| bool dragDropSuccess = false; | ||
| for (int i = 0; i < 3; i++) | ||
| { | ||
| App.DragAndDrop("Blue", "Green"); | ||
| Thread.Sleep(500); | ||
|
||
| App.WaitForElement("DropRelativeLayout"); | ||
| if (GetCoordinatesFromLabel(App.FindElement("DropRelativeLayout").GetText()) != null) | ||
| { | ||
| dragDropSuccess = true; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (!dragDropSuccess) | ||
| { | ||
| Assert.Fail("Drag-and-drop operation failed after many attempts. Drop event did not fire."); | ||
| } | ||
|
|
||
| var dropRelativeToLayout = GetCoordinatesFromLabel(App.FindElement("DropRelativeLayout").GetText()); | ||
| var dropRelativeToScreen = GetCoordinatesFromLabel(App.FindElement("DropRelativeScreen").GetText()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -835,6 +835,17 @@ public void VerifyCarouselViewWithScrollTo() | |||||||
| App.EnterText(ScrollToIndexEntry, "3"); | ||||||||
| App.WaitForElement(ScrollToButton); | ||||||||
| App.Tap(ScrollToButton); | ||||||||
| #if IOS //In CI CarouselView ScrollTo sometimes scrolls to wrong item | ||||||||
| try | ||||||||
| { | ||||||||
| App.WaitForElement("Item 4"); | ||||||||
| } | ||||||||
| catch (TimeoutException) | ||||||||
| { | ||||||||
|
||||||||
| { | |
| { | |
| TestContext.WriteLine("VerifyCarouselViewWithScrollTo: initial ScrollTo did not reach 'Item 4' within the timeout on iOS; retrying ScrollToButton tap."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
Thread.Sleep(500)is a code smell in UI tests. This hard-coded delay can cause tests to be slower than necessary or still fail if the UI isn't ready. Consider usingApp.WaitForElementor similar waiting mechanisms that poll for the expected state instead of arbitrary waits.