From 06b8841ec2e397515b33588395a81304da118b10 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Fri, 29 Mar 2024 19:00:17 +0000 Subject: [PATCH] Not only the first button click can be problematic, fix later ones. --- .../TestAppScenarios/SignalRClientTests.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/mono/wasm/Wasm.Build.Tests/TestAppScenarios/SignalRClientTests.cs b/src/mono/wasm/Wasm.Build.Tests/TestAppScenarios/SignalRClientTests.cs index eeda072308991f..0c705079d4874b 100644 --- a/src/mono/wasm/Wasm.Build.Tests/TestAppScenarios/SignalRClientTests.cs +++ b/src/mono/wasm/Wasm.Build.Tests/TestAppScenarios/SignalRClientTests.cs @@ -63,20 +63,16 @@ public async Task SignalRPassMessages(string config, string transport) } if (msg.Text.Contains("Finished GetQueryParameters")) - { - // first click after render - make sure buttons are available - await page.WaitForSelectorAsync("button#connectButton"); - await page.ClickAsync("button#connectButton"); - } + await SaveClickButtonAsync(page, "button#connectButton"); if (msg.Text.Contains("SignalR connected")) - await page.ClickAsync("button#subscribeButton"); + await SaveClickButtonAsync(page, "button#subscribeButton"); if (msg.Text.Contains("Subscribed to ReceiveMessage")) - await page.ClickAsync("button#sendMessageButton"); + await SaveClickButtonAsync(page, "button#sendMessageButton"); if (msg.Text.Contains("ReceiveMessage from server")) - await page.ClickAsync("button#exitProgramButton"); + await SaveClickButtonAsync(page, "button#exitProgramButton"); } )); @@ -95,4 +91,10 @@ private string GetThreadOfAction(string testOutput, string pattern, string actio Assert.True(match.Success, $"Expected to find a log that {actionDescription}. TestOutput: {testOutput}."); return match.Groups[1].Value ?? ""; } + + private async Task SaveClickButtonAsync(IPage page, string selector) + { + await page.WaitForSelectorAsync(selector); + await page.ClickAsync(selector); + } }