diff --git a/src/Components/test/E2ETest/Infrastructure/BasicTestAppTestBase.cs b/src/Components/test/E2ETest/Infrastructure/BasicTestAppTestBase.cs index d4933b858edb..5f95bc66d207 100644 --- a/src/Components/test/E2ETest/Infrastructure/BasicTestAppTestBase.cs +++ b/src/Components/test/E2ETest/Infrastructure/BasicTestAppTestBase.cs @@ -30,9 +30,14 @@ protected IWebElement MountTestComponent() where TComponent : ICompo { var componentTypeName = typeof(TComponent).FullName; var testSelector = WaitUntilTestSelectorReady(); + + // Wait until we've torn down any earlier component testSelector.SelectByValue("none"); + WaitUntilExists(By.Id("no-test-selected"), timeoutSeconds: 30); + + // Wait until we've done the initial render for the new component testSelector.SelectByValue(componentTypeName); - return Browser.FindElement(By.TagName("app")); + return WaitUntilExists(By.TagName("app"), timeoutSeconds: 30); } protected SelectElement WaitUntilTestSelectorReady() diff --git a/src/Components/test/E2ETest/Properties/AssemblyInfo.cs b/src/Components/test/E2ETest/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..f6e1962dd810 --- /dev/null +++ b/src/Components/test/E2ETest/Properties/AssemblyInfo.cs @@ -0,0 +1,12 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Xunit; + +// Parallelism causes issues with the server-side execution tests. It's not clear why, since +// we have separate browser and server instances for different test collections (i.e., classes) +// so they should be entirely isolated anyway. When parallelism is on, we can observe intermittent +// interference between test classes, for example test A observing the UI state of test B, which +// suggests that either Selenium has thread-safety issues that direct commands to the wrong +// browser instance, or something in our tracking of browser instances goes wrong. +[assembly: CollectionBehavior(DisableTestParallelization = true)] diff --git a/src/Components/test/E2ETest/Tests/ClientSideHostingTest.cs b/src/Components/test/E2ETest/Tests/ClientSideHostingTest.cs index 3097d06dca80..2c6a3ac0772f 100644 --- a/src/Components/test/E2ETest/Tests/ClientSideHostingTest.cs +++ b/src/Components/test/E2ETest/Tests/ClientSideHostingTest.cs @@ -71,7 +71,7 @@ public void MapFallbackToClientSideBlazor_AssemblyPath_Pattern_FilePath() private void WaitUntilLoaded() { new WebDriverWait(Browser, TimeSpan.FromSeconds(30)).Until( - driver => driver.FindElement(By.TagName("app")).Text != "Loading..."); + driver => driver.FindElement(By.Id("no-test-selected"))); } } } diff --git a/src/Components/test/testassets/BasicTestApp/Index.razor b/src/Components/test/testassets/BasicTestApp/Index.razor index 92f8d65b94d7..e4ecaf6c9868 100644 --- a/src/Components/test/testassets/BasicTestApp/Index.razor +++ b/src/Components/test/testassets/BasicTestApp/Index.razor @@ -61,9 +61,16 @@
- - @((RenderFragment)RenderSelectedComponent) - +@if (SelectedComponentType != null) +{ + + @((RenderFragment)RenderSelectedComponent) + +} +else +{ +
Select a test case from the dropdown
+} @functions { string SelectedComponentTypeName { get; set; } = "none"; @@ -73,10 +80,7 @@ void RenderSelectedComponent(RenderTreeBuilder builder) { - if (SelectedComponentType != null) - { - builder.OpenComponent(0, SelectedComponentType); - builder.CloseComponent(); - } + builder.OpenComponent(0, SelectedComponentType); + builder.CloseComponent(); } } diff --git a/src/Shared/E2ETesting/WaitAssert.cs b/src/Shared/E2ETesting/WaitAssert.cs index ded27f289f30..952f57ff94a9 100644 --- a/src/Shared/E2ETesting/WaitAssert.cs +++ b/src/Shared/E2ETesting/WaitAssert.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.E2ETesting public static class WaitAssert { - public static TimeSpan DefaultTimeout = TimeSpan.FromSeconds(3); + public static TimeSpan DefaultTimeout = TimeSpan.FromSeconds(10); public static void Equal(this IWebDriver driver, T expected, Func actual) => WaitAssertCore(driver, () => Assert.Equal(expected, actual()));