From 81c42767af8dcee1bb34352c37ae532c34e444a1 Mon Sep 17 00:00:00 2001 From: Haiping Date: Fri, 8 Aug 2025 15:38:57 -0500 Subject: [PATCH] Merge pull request #1122 from visagang/features/vguruparan Add function to get browser url for Playwright --- .../BotSharp.Abstraction/Browsing/IWebBrowser.cs | 1 + .../PlaywrightDriver/PlaywrightWebDriver.ExtractData.cs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs b/src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs index 0e6b9ba3c..eebf7bfe2 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); + string 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 b716b7bae..ff3025bde 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,11 @@ public async Task ExtractData(BrowserActionParams actionParams) return answer; } + public string GetCurrentUrl(MessageInfo message) + { + var page = _instance.GetPage(message.ContextId); + if (page == null) + return string.Empty; + return page.Url; + } }