Converting Tests back to C# but still with Playwright
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using Tests.Helpers;
|
||||
|
||||
namespace Tests.Pages;
|
||||
|
||||
public abstract class BasePage
|
||||
{
|
||||
protected Website Website { get; }
|
||||
|
||||
protected BasePage(Website website)
|
||||
{
|
||||
Website = website;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user