BotSharp/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/SeleniumDriver/SeleniumWebDriver.GetAttributeValue.cs

19 lines
608 B
C#
Raw Normal View History

2024-04-19 18:40:30 +00:00
namespace BotSharp.Plugin.WebDriver.Drivers.SeleniumDriver;
public partial class SeleniumWebDriver
{
public async Task<string> GetAttributeValue(MessageInfo message, ElementLocatingArgs location, BrowserActionResult result)
{
var driver = await _instance.InitInstance(message.ContextId);
var locator = driver.FindElement(By.CssSelector(result.Selector));
var value = string.Empty;
if (!string.IsNullOrEmpty(location?.AttributeName))
{
value = locator.GetAttribute(location.AttributeName);
}
return value ?? string.Empty;
}
}