[Testing] Fix flaky UI tests: retryTimeout and SwipeView button fix#33749
Merged
[Testing] Fix flaky UI tests: retryTimeout and SwipeView button fix#33749
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses UI test flakiness by replacing fixed Thread.Sleep delays with adaptive retryTimeout parameters in VerifyScreenshot calls, following the pattern established in PR #33705. Additionally, it eliminates network dependencies by replacing internet URLs with local image files for Issue18751 and Issue18896 tests.
Changes:
- Replaced 8 instances of
Thread.SleepwithretryTimeoutparameter for adaptive screenshot verification - Removed
#if WINDOWSconditional compilation in favor of cross-platformretryTimeout - Eliminated network dependencies by using local monkey images instead of Wikipedia URLs
- Increased timeouts and added tolerance for tests with animation timing variance
- Fixed typo in error message and corrected
isInternetRequiredflags
Reviewed changes
Copilot reviewed 13 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Issue30575.cs | Replaced 3s Thread.Sleep with retryTimeout for WebView content loading |
| Issue28657.cs | Replaced 400ms Thread.Sleep with 2s retryTimeout for orientation changes (2 occurrences) |
| Issue27418.cs | Removed Windows-specific #if directive, using retryTimeout for scrollbar timing |
| Issue25192.cs | Replaced 1s Thread.Sleep with 2s retryTimeout for CarouselView item loading |
| Issue24856.cs | Replaced Thread.Sleep + retryDelay with retryTimeout for ImageButton aspect changes |
| Issue18896.cs | Replaced Thread.Sleep + retryDelay with retryTimeout, removed internet connectivity check |
| Issue18857.cs | Replaced Thread.Sleep + retryDelay with retryTimeout for ripple animation |
| Issue18751.cs | Removed Task.Delay, changed to void method, replaced URLs with local images |
| Issue12134.cs | Increased WaitForElement timeout to 30s for WebView cookie loading, fixed typo |
| Issue10563.cs | Increased retryTimeout to 3s, added 1% tolerance for SwipeView animations |
| Issue18896.xaml.cs | Removed isInternetRequired flag since local images are now used |
| Issue18896.xaml | Added HasUnevenRows="True" for better variable height support, formatting cleanup |
| Issue18751.xaml.cs | Removed isInternetRequired flag, replaced 16 Wikipedia URLs with local image filenames |
| *.jpg (6 files) | Added local monkey images: papio, capuchin, golden, saimiri, alouatta, bluemonkey |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue18751.cs
Outdated
Show resolved
Hide resolved
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue10563.cs
Outdated
Show resolved
Hide resolved
c5d25d5 to
8de0481
Compare
Member
Author
|
/rebase |
- Issue18896: Replace Thread.Sleep with retryTimeout parameter - Issue18751: Remove isInternetRequired flag (using local images now) - Issue10563: Increase retryTimeout to 3s and add 1% tolerance for SwipeView animations
WebView loading and cookie evaluation can take time on slow networks. Increased WaitForElement timeout from default to 30 seconds.
- Issue18857: ImageButton ripple animation - Issue24856: ImageButton aspect change - Issue25192: CarouselView items loading - Issue27418: CarouselView scrollbar disappearing (Windows) - Issue28657: Orientation change screenshots - Issue30575: WebView content loading Using retryTimeout is more reliable than fixed Thread.Sleep delays as it retries the screenshot comparison until it matches.
Set Background = SolidColorBrush(Colors.LightGray) on all buttons to prevent ripple animation that causes visual differences on CI. Note: Baselines will need regeneration on CI with this change.
8de0481 to
b6349bb
Compare
Member
Author
|
/azp run maui-pr-uitests, maui-pr-devicetests |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Member
Author
|
kubaflo
pushed a commit
to kubaflo/maui
that referenced
this pull request
Feb 2, 2026
…otnet#33749) > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ## Description This PR improves the reliability of several flaky UI tests by: 1. **Replacing `Thread.Sleep` with `retryTimeout`** - The `retryTimeout` parameter keeps retrying screenshot comparisons until they match or timeout, adapting to actual UI timing across different machines/load conditions. 2. **Fixing Issue10563 SwipeView button animations** - Added flat `Background = SolidColorBrush(Colors.LightGray)` to buttons to prevent ripple animation artifacts that caused visual differences on CI. ## Changes | Test | Issue | Fix | |------|-------|-----| | Issue10563 | Button ripple animation artifacts in SwipeView test | Flat button background + updated baselines | | Issue18857 | Thread.Sleep causes flakiness | `retryTimeout: TimeSpan.FromSeconds(2)` | | Issue24856 | Thread.Sleep causes flakiness | `retryTimeout: TimeSpan.FromSeconds(2)` | | Issue25192 | Thread.Sleep causes flakiness | `retryTimeout: TimeSpan.FromSeconds(2)` | | Issue27418 | Thread.Sleep causes flakiness | `retryTimeout: TimeSpan.FromSeconds(2)` | | Issue28657 | Thread.Sleep causes flakiness | `retryTimeout: TimeSpan.FromSeconds(2)` | | Issue30575 | Thread.Sleep causes flakiness | `retryTimeout: TimeSpan.FromSeconds(3)` | ## Related PRs (not overlapping) - dotnet#33737 - Fixes Issue18751/18896 (local monkey images) - dotnet#33689 - Fixes Issue12134 (WebView cookies) --------- Co-authored-by: Ahamed-Ali <102580874+Ahamed-Ali@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description
This PR improves the reliability of several flaky UI tests by:
Replacing
Thread.SleepwithretryTimeout- TheretryTimeoutparameter keeps retrying screenshot comparisons until they match or timeout, adapting to actual UI timing across different machines/load conditions.Fixing Issue10563 SwipeView button animations - Added flat
Background = SolidColorBrush(Colors.LightGray)to buttons to prevent ripple animation artifacts that caused visual differences on CI.Changes
retryTimeout: TimeSpan.FromSeconds(2)retryTimeout: TimeSpan.FromSeconds(2)retryTimeout: TimeSpan.FromSeconds(2)retryTimeout: TimeSpan.FromSeconds(2)retryTimeout: TimeSpan.FromSeconds(2)retryTimeout: TimeSpan.FromSeconds(3)Related PRs (not overlapping)