diff --git a/src/Infrastructure/BotSharp.Abstraction/Browsing/Models/ElementActionArgs.cs b/src/Infrastructure/BotSharp.Abstraction/Browsing/Models/ElementActionArgs.cs index 869186b1..a5efa785 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Browsing/Models/ElementActionArgs.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Browsing/Models/ElementActionArgs.cs @@ -35,6 +35,12 @@ public class ElementActionArgs /// public int WaitTime { get; set; } + /// + /// Add current url to the content + /// + [JsonPropertyName("show_current_url")] + public bool ShowCurrentUrl { get; set; } = false; + /// /// Required for deserialization /// diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/UtilFunctions/UtilWebActionOnElementFn.cs b/src/Plugins/BotSharp.Plugin.WebDriver/UtilFunctions/UtilWebActionOnElementFn.cs index 0788acb8..481a6e4c 100644 --- a/src/Plugins/BotSharp.Plugin.WebDriver/UtilFunctions/UtilWebActionOnElementFn.cs +++ b/src/Plugins/BotSharp.Plugin.WebDriver/UtilFunctions/UtilWebActionOnElementFn.cs @@ -31,7 +31,7 @@ public class UtilWebActionOnElementFn : IFunctionCallback } actionArgs.WaitTime = 2; - + var conv = _services.GetRequiredService(); var services = _services.CreateScope().ServiceProvider; @@ -45,7 +45,13 @@ public class UtilWebActionOnElementFn : IFunctionCallback }; var result = await browser.ActionOnElement(msg, locatorArgs, actionArgs); - message.Content = $"{actionArgs.Action} executed {(result.IsSuccess ? "success" : "failed")}. Current page url: '{result.UrlAfterAction}'."; + message.Content = $"{actionArgs.Action} executed {(result.IsSuccess ? "success" : "failed")}."; + + // Add Current Url info to the message + if (actionArgs.ShowCurrentUrl) + { + message.Content += $" Current page url: '{result.UrlAfterAction}'."; + } var path = webDriverService.GetScreenshotFilePath(message.MessageId); diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/util-web-action_on_element.json b/src/Plugins/BotSharp.Plugin.WebDriver/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/util-web-action_on_element.json index b397fc49..35d96415 100644 --- a/src/Plugins/BotSharp.Plugin.WebDriver/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/util-web-action_on_element.json +++ b/src/Plugins/BotSharp.Plugin.WebDriver/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/util-web-action_on_element.json @@ -16,16 +16,20 @@ "content": { "type": "string", "description": "content to input in element" - }, - "file_urls": { + }, + "file_urls": { "type": "array", "description": "The output format must be string array of file urls.", "items": { - "type": "string", - "description": "file url" + "type": "string", + "description": "file url" } + }, + "show_current_url": { + "type": "boolean", + "description": "check if need to extract the current url" }, - "press_key": { + "press_key": { "type": "string", "enum": [ "Enter" ], "description": "press key after input text"