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";
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
TemplateName = $"{GO_TO_PAGE_FN}.fn"
|
|
|
|
|
},
|
|
|
|
|
new UtilityItem
|
|
|
|
|
{
|
|
|
|
|
FunctionName = ACTION_ON_ELEMENT_FN,
|
|
|
|
|
TemplateName = $"{ACTION_ON_ELEMENT_FN}.fn"
|
|
|
|
|
},
|
|
|
|
|
new UtilityItem
|
|
|
|
|
{
|
|
|
|
|
FunctionName = LOCATE_ELEMENT_FN
|
|
|
|
|
},
|
|
|
|
|
new UtilityItem
|
|
|
|
|
{
|
|
|
|
|
FunctionName = CLOSE_BROWSER_FN
|
|
|
|
|
}
|
2025-02-03 23:43:04 +00:00
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
utilities.AddRange(items);
|
|
|
|
|
}
|
|
|
|
|
}
|