BotSharp/src/Plugins/BotSharp.Plugin.WebDriver/Functions/SwitchToNewTab.cs
2024-02-01 22:16:57 -06:00

27 lines
741 B
C#

using BotSharp.Plugin.WebDriver.Drivers.PlaywrightDriver;
namespace BotSharp.Plugin.WebDriver.Functions;
public class SwitchToNewTab : IFunctionCallback
{
public string Name => "switch_to_new_tab";
private readonly IServiceProvider _services;
private readonly PlaywrightWebDriver _driver;
public SwitchToNewTab(IServiceProvider services,
PlaywrightWebDriver driver)
{
_services = services;
_driver = driver;
}
public async Task<bool> Execute(RoleDialogModel message)
{
var args = JsonSerializer.Deserialize<BrowsingContextIn>(message.FunctionArgs);
await _driver.SwitchToNewTab();
message.Content = "Switched to new tab page";
return true;
}
}