BotSharp/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.GetAttributeValue.cs

19 lines
598 B
C#
Raw Normal View History

2024-03-22 19:12:45 +00:00
namespace BotSharp.Plugin.WebDriver.Drivers.PlaywrightDriver;
public partial class PlaywrightWebDriver
{
public async Task<string> GetAttributeValue(MessageInfo message, ElementLocatingArgs location, BrowserActionResult result)
{
var page = _instance.GetPage(message.ConversationId);
ILocator locator = page.Locator(result.Selector);
var value = string.Empty;
if (!string.IsNullOrEmpty(location?.AttributeName))
{
value = await locator.GetAttributeAsync(location.AttributeName);
}
return value ?? string.Empty;
}
}