2024-12-21 00:39:35 +00:00
|
|
|
namespace BotSharp.Plugin.Selenium.Drivers;
|
2024-04-19 18:40:30 +00:00
|
|
|
|
|
|
|
|
public partial class SeleniumWebDriver
|
|
|
|
|
{
|
2024-04-30 12:50:01 +00:00
|
|
|
public async Task<BrowserActionResult> GetAttributeValue(MessageInfo message, ElementLocatingArgs location)
|
2024-04-19 18:40:30 +00:00
|
|
|
{
|
|
|
|
|
var driver = await _instance.InitInstance(message.ContextId);
|
2024-04-30 12:50:01 +00:00
|
|
|
var locator = driver.FindElement(By.CssSelector(location.Selector));
|
2024-04-19 18:40:30 +00:00
|
|
|
var value = string.Empty;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(location?.AttributeName))
|
|
|
|
|
{
|
|
|
|
|
value = locator.GetAttribute(location.AttributeName);
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-30 12:50:01 +00:00
|
|
|
return new BrowserActionResult
|
|
|
|
|
{
|
|
|
|
|
IsSuccess = true,
|
|
|
|
|
Body = value ?? string.Empty
|
|
|
|
|
};
|
2024-04-19 18:40:30 +00:00
|
|
|
}
|
|
|
|
|
}
|