BotSharp/src/Plugins/BotSharp.Plugin.WebDriver/Hooks/WebUtilityHook.cs

48 lines
1.5 KiB
C#
Raw Normal View History

2025-02-03 23:43:04 +00:00
namespace BotSharp.Plugin.WebDriver.Hooks;
public class WebUtilityHook : IAgentUtilityHook
{
private const string PREFIX = "util-web-";
2025-02-04 21:56:25 +00:00
private const string CLOSE_BROWSER_FN = $"{PREFIX}close_browser";
2025-02-03 23:43:04 +00:00
private const string GO_TO_PAGE_FN = $"{PREFIX}go_to_page";
2025-02-04 21:56:25 +00:00
private const string LOCATE_ELEMENT_FN = $"{PREFIX}locate_element";
2025-02-03 23:43:04 +00:00
private const string ACTION_ON_ELEMENT_FN = $"{PREFIX}action_on_element";
2025-09-30 21:39:58 +00:00
private const string TAKE_SCREENSHOT_FN = $"{PREFIX}take_screenshot";
2025-02-03 23:43:04 +00:00
public void AddUtilities(List<AgentUtility> utilities)
{
var items = new List<AgentUtility>
{
new AgentUtility
{
2025-05-28 21:16:48 +00:00
Category = "web",
Name = "browser.tools",
Items = [
new UtilityItem
{
FunctionName = GO_TO_PAGE_FN,
},
new UtilityItem
{
FunctionName = ACTION_ON_ELEMENT_FN,
},
new UtilityItem
{
FunctionName = LOCATE_ELEMENT_FN
},
new UtilityItem
{
FunctionName = CLOSE_BROWSER_FN
2025-09-30 21:39:58 +00:00
},
new UtilityItem
{
FunctionName = TAKE_SCREENSHOT_FN
2025-05-28 21:16:48 +00:00
}
2025-02-03 23:43:04 +00:00
]
}
};
utilities.AddRange(items);
}
}