[Testing] Fix for flaky device test BlazorWebViewUsesStartPath on Windows#29966
[Testing] Fix for flaky device test BlazorWebViewUsesStartPath on Windows#29966PureWeen merged 3 commits intoinflight/currentfrom unknown repository
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 <175728472+Copilot@users.noreply.github.com>
|
/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.
Isn't this called by the handler already?
There was a problem hiding this comment.
@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.
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 <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…dows (#29966) * Update WebViewHelpers.Windows.cs * Update WebViewHelpers.Windows.cs * Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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
WaitForWebViewReadymethod inWebViewHelpers.Windows.csto 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.