diff --git a/src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs b/src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs index 9386dd8a..0e6b9ba3 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs @@ -25,6 +25,7 @@ public interface IWebBrowser Task ExtractData(BrowserActionParams actionParams); Task EvaluateScript(string contextId, string script); Task CloseBrowser(string contextId); + Task IsBrowserClosed(string contextId); Task CloseCurrentPage(MessageInfo message); Task SendHttpRequest(MessageInfo message, HttpRequestParams actionParams); Task GetAttributeValue(MessageInfo message, ElementLocatingArgs location); diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.cs b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.cs index 4d13e26f..67c9bf8d 100644 --- a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.cs +++ b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.cs @@ -78,4 +78,9 @@ public partial class PlaywrightWebDriver : IWebBrowser await page.Keyboard.PressAsync(key); } } + + public async Task IsBrowserClosed(string contextId) + { + return !_instance.Contexts.ContainsKey(contextId); + } }