Skip to content

Commit 8c93870

Browse files
authored
Merge pull request #980 from evan-cao-wb/master
Add UrlAfterAction into Content
2 parents da14d00 + 2a322f6 commit 8c93870

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

src/Infrastructure/BotSharp.Abstraction/Browsing/Models/ElementActionArgs.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ public class ElementActionArgs
3535
/// </summary>
3636
public int WaitTime { get; set; }
3737

38+
/// <summary>
39+
/// Add current url to the content
40+
/// </summary>
41+
[JsonPropertyName("show_current_url")]
42+
public bool ShowCurrentUrl { get; set; } = false;
43+
3844
/// <summary>
3945
/// Required for deserialization
4046
/// </summary>

src/Plugins/BotSharp.Plugin.WebDriver/BotSharp.Plugin.WebDriver.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>$(TargetFramework)</TargetFramework>

src/Plugins/BotSharp.Plugin.WebDriver/UtilFunctions/UtilWebActionOnElementFn.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public async Task<bool> Execute(RoleDialogModel message)
3131
}
3232

3333
actionArgs.WaitTime = 2;
34-
34+
3535
var conv = _services.GetRequiredService<IConversationService>();
3636

3737
var services = _services.CreateScope().ServiceProvider;
@@ -45,7 +45,13 @@ public async Task<bool> Execute(RoleDialogModel message)
4545
};
4646
var result = await browser.ActionOnElement(msg, locatorArgs, actionArgs);
4747

48-
message.Content = $"{actionArgs.Action} executed {(result.IsSuccess ? "success" : "failed")}";
48+
message.Content = $"{actionArgs.Action} executed {(result.IsSuccess ? "success" : "failed")}.";
49+
50+
// Add Current Url info to the message
51+
if (actionArgs.ShowCurrentUrl)
52+
{
53+
message.Content += $" Current page url: '{result.UrlAfterAction}'.";
54+
}
4955

5056
var path = webDriverService.GetScreenshotFilePath(message.MessageId);
5157

src/Plugins/BotSharp.Plugin.WebDriver/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/util-web-action_on_element.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,20 @@
1616
"content": {
1717
"type": "string",
1818
"description": "content to input in element"
19-
},
20-
"file_urls": {
19+
},
20+
"file_urls": {
2121
"type": "array",
2222
"description": "The output format must be string array of file urls.",
2323
"items": {
24-
"type": "string",
25-
"description": "file url"
24+
"type": "string",
25+
"description": "file url"
2626
}
27+
},
28+
"show_current_url": {
29+
"type": "boolean",
30+
"description": "check if need to extract the current url"
2731
},
28-
"press_key": {
32+
"press_key": {
2933
"type": "string",
3034
"enum": [ "Enter" ],
3135
"description": "press key after input text"

0 commit comments

Comments
 (0)