add AvatarBase64

This commit is contained in:
jason 2024-11-25 22:20:32 +08:00
parent f722781be4
commit 97e0b687ce
2 changed files with 13 additions and 0 deletions

View file

@ -36,4 +36,5 @@ public class ElementLocatingArgs
/// </summary>
public bool Highlight { get; set; }
public string HighlightColor { get; set; } = "red";
public bool IsImage { get; set; }
}

View file

@ -17,6 +17,18 @@ public partial class PlaywrightWebDriver
ILocator locator = page.Locator("body");
int count = 0;
if (location.IsImage)
{
var handle = await page.QuerySelectorAsync("img");
byte[]? imageBytes = handle != null ? await handle.ScreenshotAsync() : null;
string? body = null;
if (imageBytes?.Any() == true)
{
body = Convert.ToBase64String(imageBytes);
}
return new BrowserActionResult { IsSuccess = true, Body = body };
}
// check if selector is specified
if (location.Selector != null)
{