Converting Tests back to C# but still with Playwright

This commit is contained in:
2026-06-03 14:45:18 -04:00
parent 85834466f1
commit 46150d3a69
209 changed files with 1503 additions and 683 deletions
+50
View File
@@ -0,0 +1,50 @@
using Microsoft.Playwright;
using Tests.Pages;
using Tests.Shared;
namespace Tests.Helpers;
public class Website
{
public IPage Page { get; }
public bool RunAgainstProduction { get; }
public string BaseUrl { get; }
public Website(IPage page)
{
Page = page;
RunAgainstProduction = Environment.GetEnvironmentVariable("RUN_AGAINST_PRODUCTION") == "true";
BaseUrl = RunAgainstProduction ? "https://igpfanreference.ca" : (LocalServer.BaseUrl ?? "http://localhost:5234");
NavigationBar = new NavigationBar(this);
SearchDialog = new SearchDialog(this);
BuildCalculatorPage = new BuildCalculatorPage(this);
HarassCalculatorPage = new HarassCalculatorPage(this);
DatabasePage = new DatabasePage(this);
DatabaseSinglePage = new DatabaseSinglePage(this);
}
public ILocator Locator(string selector) => Page.Locator(selector);
public ILocator FindById(string id) => Page.Locator($"#{id}");
public NavigationBar NavigationBar { get; }
public SearchDialog SearchDialog { get; }
public BuildCalculatorPage BuildCalculatorPage { get; }
public HarassCalculatorPage HarassCalculatorPage { get; }
public DatabasePage DatabasePage { get; }
public DatabaseSinglePage DatabaseSinglePage { get; }
public async Task GotoAsync(string? path = null)
{
var url = path is null ? BaseUrl : $"{BaseUrl}/{path}";
await Page.GotoAsync(url);
}
public async Task ClickElementAsync(ILocator locator) => await locator.ClickAsync();
public async Task EnterInputAsync(ILocator locator, string value)
{
await locator.FillAsync(value);
await locator.PressAsync("Enter");
}
}