Skip to content

Commit f659457

Browse files
committed
Cleanup E2E test scripts
1 parent bb26cf8 commit f659457

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -191,38 +191,33 @@ public async Task BlazorServerTemplateWorks_IndividualAuth(BrowserKind browserKi
191191

192192
private async Task TestBasicNavigation(IPage page)
193193
{
194-
await page.QuerySelectorAsync("ul");
194+
IWebSocket socket = null;
195+
await page.WaitForEventAsync(PageEvent.WebSocket, s => (socket = s.WebSocket) != null);
196+
await socket.WaitForEventAsync(WebSocketEvent.FrameReceived);
197+
198+
await page.WaitForSelectorAsync("ul");
195199
// <title> element gets project ID injected into it during template execution
196200
Assert.Equal(Project.ProjectName.Trim(), (await page.GetTitleAsync()).Trim());
197201

198202
// Initially displays the home page
199-
Assert.Equal("Hello, world!", await page.GetTextContentAsync("h1"));
203+
await page.WaitForSelectorAsync("h1 >> text=Hello, world!");
200204

201205
// Can navigate to the counter page
202-
203206
await Task.WhenAll(
204207
page.WaitForNavigationAsync("**/counter"),
205-
page.WaitForSelectorAsync("text=Current count: 0"),
206-
page.ClickAsync("text=Counter"));
207-
208-
Assert.Equal("Counter", await page.GetTextContentAsync("h1"));
208+
page.WaitForSelectorAsync("h1+p >> text=Current count: 0"),
209+
page.ClickAsync("a[href=counter] >> text=Counter"));
209210

210211
// Clicking the counter button works
211-
Assert.Equal("Current count: 0", await page.GetTextContentAsync("h1+p"));
212-
await page.WaitForTimeoutAsync(1000);
213212
await Task.WhenAll(
214-
page.WaitForSelectorAsync("text=Current count: 1"),
215-
page.ClickAsync("p+button"));
216-
217-
Assert.Equal("Current count: 1", await page.GetTextContentAsync("h1+p"));
213+
page.WaitForSelectorAsync("h1+p >> text=Current count: 1"),
214+
page.ClickAsync("p+button >> text=Click me"));
218215

219216
// Can navigate to the 'fetch data' page
220217
await Task.WhenAll(
221218
page.WaitForNavigationAsync("**/fetchdata"),
222-
page.WaitForSelectorAsync("text=Weather forecast"),
223-
page.ClickAsync("text=Fetch data"));
224-
225-
Assert.Equal("Weather forecast", await page.GetTextContentAsync("h1"));
219+
page.WaitForSelectorAsync("h1 >> text=Weather forecast"),
220+
page.ClickAsync("a[href=fetchdata] >> text=Fetch data"));
226221

227222
// Asynchronously loads and displays the table of weather forecasts
228223
await page.WaitForSelectorAsync("table>tbody>tr");

src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ await Task.WhenAll(
569569
// Clicking the counter button works
570570
await Task.WhenAll(
571571
page.WaitForSelectorAsync("p >> text=Current count: 1"),
572-
page.ClickAsync("p+button"));
572+
page.ClickAsync("p+button >> text=Click me"));
573573

574574
if (usesAuth)
575575
{
@@ -616,11 +616,9 @@ await Task.WhenAll(
616616
// Can navigate to the 'fetch data' page
617617
await Task.WhenAll(
618618
page.WaitForNavigationAsync("**/fetchdata"),
619-
page.WaitForSelectorAsync("text=Weather forecast"),
619+
page.WaitForSelectorAsync("h1 >> text=Weather forecast"),
620620
page.ClickAsync("text=Fetch data"));
621621

622-
Assert.Equal("Weather forecast", await page.GetInnerTextAsync("h1"));
623-
624622
// Asynchronously loads and displays the table of weather forecasts
625623
await page.WaitForSelectorAsync("table>tbody>tr");
626624
Assert.Equal(5, (await page.QuerySelectorAllAsync("p+table>tbody>tr")).Count());

0 commit comments

Comments
 (0)