diff --git a/src/Components/test/E2ETest/Tests/SectionsWithCascadingParametersTest.cs b/src/Components/test/E2ETest/Tests/SectionsWithCascadingParametersTest.cs index a0a010122c16..42a249ae019a 100644 --- a/src/Components/test/E2ETest/Tests/SectionsWithCascadingParametersTest.cs +++ b/src/Components/test/E2ETest/Tests/SectionsWithCascadingParametersTest.cs @@ -14,6 +14,8 @@ namespace Microsoft.AspNetCore.Components.E2ETests.Tests; public class SectionsWithCascadingParametersTest : ServerTestBase> { + private IWebElement _appElement; + public SectionsWithCascadingParametersTest (BrowserFixture browserFixture, ToggleExecutionModeServerFixture serverFixture, @@ -25,7 +27,7 @@ public SectionsWithCascadingParametersTest protected override void InitializeAsyncCore() { Navigate(ServerPathBase, noReload: _serverFixture.ExecutionMode == ExecutionMode.Client); - Browser.MountTestComponent(); + _appElement = Browser.MountTestComponent(); } [Fact] @@ -35,7 +37,7 @@ public void RenderSectionContent_CascadingParameterForSectionOutletIsDeterminedB Browser.FindElement(By.Id("render-section-outlet")).Click(); Browser.FindElement(By.Id("render-second-section-content")).Click(); - Browser.Equal("Second Section with additional text for second section", () => Browser.Exists(By.TagName("p")).Text); + Browser.Equal("Second Section with additional text for second section", () => _appElement.FindElement(By.TagName("p")).Text); } [Fact] @@ -46,7 +48,7 @@ public void ChangeCascadingValueForSectionContent_CascadingValueForSectionOutlet Browser.FindElement(By.Id("change-cascading-value")).Click(); - Browser.Equal("First Section with additional text for second section", () => Browser.Exists(By.TagName("p")).Text); + Browser.Equal("First Section with additional text for second section", () => _appElement.FindElement(By.TagName("p")).Text); } [Fact] @@ -56,7 +58,7 @@ public void RenderTwoSectionContentsWithSameId_CascadingParameterForSectionOutle Browser.FindElement(By.Id("render-first-section-content")).Click(); Browser.FindElement(By.Id("render-section-outlet")).Click(); - Browser.Equal("First Section with additional text for first section", () => Browser.Exists(By.TagName("p")).Text); + Browser.Equal("First Section with additional text for first section", () => _appElement.FindElement(By.TagName("p")).Text); } [Fact] @@ -68,7 +70,7 @@ public void SecondSectionContentIdChanged_CascadingParameterForSectionOutletIsDe Browser.FindElement(By.Id("change-second-section-content-id")).Click(); - Browser.Equal("First Section with additional text for first section", () => Browser.Exists(By.TagName("p")).Text); + Browser.Equal("First Section with additional text for first section", () => _appElement.FindElement(By.TagName("p")).Text); } [Fact] @@ -80,7 +82,7 @@ public void SecondSectionContentDisposed_CascadingParameterForSectionOutletIsDet Browser.FindElement(By.Id("dispose-second-section-content")).Click(); - Browser.Equal("First Section with additional text for first section", () => Browser.Exists(By.TagName("p")).Text); + Browser.Equal("First Section with additional text for first section", () => _appElement.FindElement(By.TagName("p")).Text); } [Fact] @@ -92,7 +94,7 @@ public void FirstSectionContentDisposedThenRenderSecondSectionContent_CascadingP Browser.FindElement(By.Id("dispose-first-section-content")).Click(); Browser.FindElement(By.Id("render-second-section-content")).Click(); - Browser.Equal("Second Section with additional text for second section", () => Browser.Exists(By.TagName("p")).Text); + Browser.Equal("Second Section with additional text for second section", () => _appElement.FindElement(By.TagName("p")).Text); } [Fact] @@ -105,6 +107,6 @@ public void SectionOutletIdChanged_CascadingParameterForSectionOutletIsDetermine Browser.FindElement(By.Id("change-section-outlet-id")).Click(); - Browser.Equal("Second Section with additional text for second section", () => Browser.Exists(By.TagName("p")).Text); + Browser.Equal("Second Section with additional text for second section", () => _appElement.FindElement(By.TagName("p")).Text); } } diff --git a/src/Components/test/E2ETest/Tests/SectionsWithErrorBoundaryTest.cs b/src/Components/test/E2ETest/Tests/SectionsWithErrorBoundaryTest.cs index 3bd735cac6f7..9e103f046bd8 100644 --- a/src/Components/test/E2ETest/Tests/SectionsWithErrorBoundaryTest.cs +++ b/src/Components/test/E2ETest/Tests/SectionsWithErrorBoundaryTest.cs @@ -14,6 +14,8 @@ namespace Microsoft.AspNetCore.Components.E2ETests.Tests; public class SectionsWithErrorBoundaryTest : ServerTestBase> { + private IWebElement _appElement; + public SectionsWithErrorBoundaryTest (BrowserFixture browserFixture, ToggleExecutionModeServerFixture serverFixture, @@ -25,7 +27,7 @@ public SectionsWithErrorBoundaryTest protected override void InitializeAsyncCore() { Navigate(ServerPathBase, noReload: _serverFixture.ExecutionMode == ExecutionMode.Client); - Browser.MountTestComponent(); + _appElement = Browser.MountTestComponent(); } [Fact] @@ -37,7 +39,7 @@ public void RenderSectionContent_ErrorBoundaryForSectionOutletContentIsDetermine Browser.FindElement(By.Id("error-button")).Click(); - Browser.Equal("Sorry!", () => Browser.Exists(By.TagName("p")).Text); + Browser.Equal("Sorry!", () => _appElement.FindElement(By.TagName("p")).Text); } [Fact] @@ -88,7 +90,7 @@ public void FirstSectionContentDisposedThenRenderSecondSectionContent_ErrorBound Browser.FindElement(By.Id("render-second-section-content")).Click(); Browser.FindElement(By.Id("error-button")).Click(); - Browser.Equal("Sorry!", () => Browser.Exists(By.TagName("p")).Text); + Browser.Equal("Sorry!", () => _appElement.FindElement(By.TagName("p")).Text); } [Fact] @@ -102,6 +104,6 @@ public void SectionOutletIdChanged_ErrorBoundaryForSectionOutletIsDeterminedByMa Browser.FindElement(By.Id("change-section-outlet-id")).Click(); Browser.FindElement(By.Id("error-button")).Click(); - Browser.Equal("Sorry!", () => Browser.Exists(By.TagName("p")).Text); + Browser.Equal("Sorry!", () => _appElement.FindElement(By.TagName("p")).Text); } }