Skip to content

Commit 9beea89

Browse files
authored
Merge pull request #996 from visagang/features/vguruparan
add read content to locate element utility
2 parents f1fe571 + fc1af80 commit 9beea89

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ public class ElementLocatingArgs
3636
/// </summary>
3737
public bool Highlight { get; set; }
3838
public string HighlightColor { get; set; } = "red";
39+
[JsonPropertyName("is_read_content")]
40+
public bool IsReadContent { get;set; }
3941
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ public async Task<bool> Execute(RoleDialogModel message)
3232
};
3333
var result = await browser.LocateElement(msg, locatorArgs);
3434

35-
message.Content = $"Locating element {(result.IsSuccess ? "success" : "failed")}";
35+
message.Content = $"Locating element {(result.IsSuccess ? "success" : "failed")}. ";
36+
if (locatorArgs.IsReadContent && result.IsSuccess && !string.IsNullOrWhiteSpace(result.Body))
37+
{
38+
message.Content += $"Content is: \n{result.Body}";
39+
}
3640

3741
var path = webDriverService.GetScreenshotFilePath(message.MessageId);
3842

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"selector": {
88
"type": "string",
99
"description": "element selector in XPath, use syntax of Playwright in .NET"
10+
},
11+
"is_read_content": {
12+
"type": "boolean",
13+
"description": "read the content"
1014
}
1115
},
1216
"required": [ "selector" ]

0 commit comments

Comments
 (0)