-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Testing] Fix for flaky device test BlazorWebViewUsesStartPath on Windows #29966
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
[Testing] Fix for flaky device test BlazorWebViewUsesStartPath on Windows #29966
Conversation
Hey there @@anandhan-rajagopal! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Co-authored-by: Copilot <[email protected]>
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
{ | ||
throw new InvalidOperationException("WebView2 runtime is not installed."); | ||
} | ||
await wv2.EnsureCoreWebView2Async(); |
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.
Isn't this called by the handler already?
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.
@mattleibow Yes, it was invoked in the handler already. However, the test failed in CI with the error 'Waited 30000ms but couldn't get CoreWebView2 to be available'. To address this, the call was added again to explicitly ensure proper initialization before the test begins, along with appropriate exception handling.
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.
Pull Request Overview
This PR fixes flaky device tests for BlazorWebView on Windows by ensuring the WebView2 runtime is available and initialized before proceeding with the tests.
- Adds a check for the WebView2 runtime availability using CoreWebView2Environment.GetAvailableBrowserVersionString.
- Calls EnsureCoreWebView2Async when the CoreWebView2 instance is not yet available.
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
Description
This PR addresses the flakiness observed in Blazor device tests, particularly the recurring error:
Build Link: https://dev.azure.com/xamarin/public/_build/results?buildId=143779&view=ms.vss-test-web.build-test-results-tab&runId=4309282&resultId=100000&paneView=debug
Root Cause
The failure is due to the WebView2 runtime not being available or failing to initialize in certain test environments. This is not related to the test logic but rather a system setup issue—specifically, the runtime dependency on a Windows GUI environment with WebView2 support.
Solution Description
Solution added
WaitForWebViewReady
method inWebViewHelpers.Windows.cs
to ensure that the WebView2 runtime is properly installed and initialized before proceeding. The key change adds a check for the WebView2 runtime and initializes it if necessary.