Skip to content

Commit 97e0b68

Browse files
author
jason
committed
add AvatarBase64
1 parent f722781 commit 97e0b68

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ public class ElementLocatingArgs
3636
/// </summary>
3737
public bool Highlight { get; set; }
3838
public string HighlightColor { get; set; } = "red";
39+
public bool IsImage { get; set; }
3940
}

src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.LocateElement.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ public async Task<BrowserActionResult> LocateElement(MessageInfo message, Elemen
1717
ILocator locator = page.Locator("body");
1818
int count = 0;
1919

20+
if (location.IsImage)
21+
{
22+
var handle = await page.QuerySelectorAsync("img");
23+
byte[]? imageBytes = handle != null ? await handle.ScreenshotAsync() : null;
24+
string? body = null;
25+
if (imageBytes?.Any() == true)
26+
{
27+
body = Convert.ToBase64String(imageBytes);
28+
}
29+
return new BrowserActionResult { IsSuccess = true, Body = body };
30+
}
31+
2032
// check if selector is specified
2133
if (location.Selector != null)
2234
{

0 commit comments

Comments
 (0)