namespace Tests.Pages.BuildCalculator; public class EntityClickViewComponent { private readonly Website _website; public EntityClickViewComponent(Website website) => _website = website; public ILocator EntityClickView => _website.Locator(".entityClickView"); public async Task GetEntityNameAsync() { var el = EntityClickView.Locator("#entityName"); if (await el.CountAsync() == 0) return null; return (await el.TextContentAsync())?.Trim(); } public async Task GetEntityHealthAsync() { var healthText = EntityClickView.Locator("div").Filter(new() { HasTextRegex = new System.Text.RegularExpressions.Regex("Health", System.Text.RegularExpressions.RegexOptions.IgnoreCase) }).First; if (await healthText.CountAsync() == 0) return null; var text = (await healthText.TextContentAsync()) ?? ""; var match = System.Text.RegularExpressions.Regex.Match(text, @"(\d+)"); return match.Success ? match.Groups[1].Value : null; } public async Task ClickDetailedViewAsync() => await EntityClickView.Locator("button").Filter(new() { HasText = "Detailed" }).ClickAsync(); public async Task ClickPlainViewAsync() => await EntityClickView.Locator("button").Filter(new() { HasText = "Plain" }).ClickAsync(); }