Improve robustness of components Bind and EventBubbling E2E tests
This commit is contained in:
parent
8759518a97
commit
e0007f4f4b
|
|
@ -38,9 +38,16 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Infrastructure
|
||||||
protected SelectElement WaitUntilTestSelectorReady()
|
protected SelectElement WaitUntilTestSelectorReady()
|
||||||
{
|
{
|
||||||
var elemToFind = By.CssSelector("#test-selector > select");
|
var elemToFind = By.CssSelector("#test-selector > select");
|
||||||
new WebDriverWait(Browser, TimeSpan.FromSeconds(30)).Until(
|
WaitUntilExists(elemToFind, timeoutSeconds: 30);
|
||||||
driver => driver.FindElement(elemToFind) != null);
|
|
||||||
return new SelectElement(Browser.FindElement(elemToFind));
|
return new SelectElement(Browser.FindElement(elemToFind));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IWebElement WaitUntilExists(By findBy, int timeoutSeconds = 10)
|
||||||
|
{
|
||||||
|
IWebElement result = null;
|
||||||
|
new WebDriverWait(Browser, TimeSpan.FromSeconds(timeoutSeconds))
|
||||||
|
.Until(driver => (result = driver.FindElement(findBy)) != null);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using BasicTestApp;
|
using BasicTestApp;
|
||||||
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
|
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
|
||||||
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
|
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
|
||||||
|
|
@ -28,6 +27,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
|
||||||
// On WebAssembly, page reloads are expensive so skip if possible
|
// On WebAssembly, page reloads are expensive so skip if possible
|
||||||
Navigate(ServerPathBase, noReload: !_serverFixture.UsingAspNetHost);
|
Navigate(ServerPathBase, noReload: !_serverFixture.UsingAspNetHost);
|
||||||
MountTestComponent<BindCasesComponent>();
|
MountTestComponent<BindCasesComponent>();
|
||||||
|
WaitUntilExists(By.Id("bind-cases"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
|
||||||
{
|
{
|
||||||
Navigate(ServerPathBase, noReload: !_serverFixture.UsingAspNetHost);
|
Navigate(ServerPathBase, noReload: !_serverFixture.UsingAspNetHost);
|
||||||
MountTestComponent<EventBubblingComponent>();
|
MountTestComponent<EventBubblingComponent>();
|
||||||
|
WaitUntilExists(By.Id("event-bubbling"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
<h3 id="bind-cases">Bind cases</h3>
|
||||||
|
|
||||||
<h2>Textbox</h2>
|
<h2>Textbox</h2>
|
||||||
<p>
|
<p>
|
||||||
Initially blank:
|
Initially blank:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<h3>Bubbling standard event</h3>
|
<h3 id="event-bubbling">Bubbling standard event</h3>
|
||||||
|
|
||||||
<div onclick="@(() => LogEvent("parent onclick"))">
|
<div onclick="@(() => LogEvent("parent onclick"))">
|
||||||
<button id="button-with-onclick" onclick="@(() => LogEvent("target onclick"))">Button with onclick handler</button>
|
<button id="button-with-onclick" onclick="@(() => LogEvent("target onclick"))">Button with onclick handler</button>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue