Files
IGP-Fan-Reference/Tests/Pages/BuildCalculator/EntityClickViewComponent.cs
T

32 lines
1.3 KiB
C#

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<string?> GetEntityNameAsync()
{
var el = EntityClickView.Locator("#entityName");
if (await el.CountAsync() == 0) return null;
return (await el.TextContentAsync())?.Trim();
}
public async Task<string?> 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();
}