From d30c17365b48f8024cfaa076bea38b2c64543bdf Mon Sep 17 00:00:00 2001 From: vguruparan Date: Fri, 8 Aug 2025 13:58:30 -0500 Subject: [PATCH] Add function to get browser url for Playwright --- .../BotSharp.Abstraction/Browsing/IWebBrowser.cs | 1 + .../PlaywrightDriver/PlaywrightWebDriver.ExtractData.cs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs b/src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs index 0e6b9ba3..327b2f99 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs @@ -30,4 +30,5 @@ public interface IWebBrowser Task SendHttpRequest(MessageInfo message, HttpRequestParams actionParams); Task GetAttributeValue(MessageInfo message, ElementLocatingArgs location); Task SetAttributeValue(MessageInfo message, ElementLocatingArgs location); + Task GetCurrentUrl(MessageInfo message); } diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.ExtractData.cs b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.ExtractData.cs index b716b7ba..9f5f4727 100644 --- a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.ExtractData.cs +++ b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.ExtractData.cs @@ -17,4 +17,12 @@ public partial class PlaywrightWebDriver return answer; } + public async Task GetCurrentUrl(MessageInfo message) + { + var page = _instance.GetPage(message.ContextId); + if (page == null) + return string.Empty; + return page.Url; + + } }