namespace Tests.Pages;

public abstract class BasePage
{
    protected BasePage(Website website)
    {
        Website = website;
    }

    protected Website Website { get; }

    public abstract string Url { get; }

    public virtual async Task GotoAsync()
    {
        await Website.GotoAsync(Url);
    }

    public async Task<List<string>> GetLinksAsync()
    {
        var content = Website.FindById("content");
        var links = content.Locator("a");
        var hrefs = await links.EvaluateAllAsync<string[]>(
            "els => els.map(el => el.getAttribute('href')).filter(Boolean)");
        return hrefs.ToList();
    }
}