Migrate UI tests to Playwright dotta
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
using Microsoft.Playwright;
|
||||
|
||||
namespace JdeScoping.Ui.Tests.Helpers;
|
||||
|
||||
internal static class UiAuthHelper
|
||||
@@ -7,11 +5,8 @@ internal static class UiAuthHelper
|
||||
public static async Task LoginAsync(IPage page, string username = "testuser", string password = "testpass")
|
||||
{
|
||||
var loginForm = page.GetByText("Authentication Required");
|
||||
var formVisible = await loginForm.IsVisibleAsync();
|
||||
if (!formVisible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool formVisible = await loginForm.IsVisibleAsync();
|
||||
if (!formVisible) return;
|
||||
|
||||
await page.Locator("input[name='Username']").FillAsync(username);
|
||||
await page.Locator("input[name='Password']").FillAsync(password);
|
||||
@@ -25,15 +20,12 @@ internal static class UiAuthHelper
|
||||
if (await loginForm.IsVisibleAsync())
|
||||
{
|
||||
var notifications = page.Locator(".rz-notification");
|
||||
var count = await notifications.CountAsync();
|
||||
int count = await notifications.CountAsync();
|
||||
var details = new List<string>();
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var text = (await notifications.Nth(i).InnerTextAsync()).Trim();
|
||||
if (!string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
details.Add(text);
|
||||
}
|
||||
string text = (await notifications.Nth(i).InnerTextAsync()).Trim();
|
||||
if (!string.IsNullOrWhiteSpace(text)) details.Add(text);
|
||||
}
|
||||
|
||||
throw new InvalidOperationException(
|
||||
@@ -50,4 +42,4 @@ internal static class UiAuthHelper
|
||||
await page.WaitForLoadStateAsync(LoadState.NetworkIdle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user