2024-02-06 14:07:09 +00:00
|
|
|
namespace BotSharp.Plugin.WebDriver.Drivers.PlaywrightDriver;
|
|
|
|
|
|
|
|
|
|
public partial class PlaywrightWebDriver
|
|
|
|
|
{
|
2024-03-08 13:17:36 +00:00
|
|
|
public async Task<BrowserActionResult> ScreenshotAsync(string conversationId, string path)
|
2024-02-06 14:07:09 +00:00
|
|
|
{
|
2024-03-08 13:17:36 +00:00
|
|
|
var result = new BrowserActionResult();
|
|
|
|
|
|
2024-02-15 21:55:50 +00:00
|
|
|
await _instance.Wait(conversationId);
|
|
|
|
|
var page = _instance.GetPage(conversationId);
|
|
|
|
|
|
|
|
|
|
await Task.Delay(500);
|
|
|
|
|
var bytes = await page.ScreenshotAsync(new PageScreenshotOptions
|
|
|
|
|
{
|
2024-03-08 13:17:36 +00:00
|
|
|
Path = path,
|
|
|
|
|
FullPage = true
|
2024-02-15 21:55:50 +00:00
|
|
|
});
|
2024-02-06 14:07:09 +00:00
|
|
|
|
2024-03-08 13:17:36 +00:00
|
|
|
result.IsSuccess = true;
|
|
|
|
|
result.Body = "data:image/png;base64," + Convert.ToBase64String(bytes);
|
|
|
|
|
return result;
|
2024-02-06 14:07:09 +00:00
|
|
|
}
|
|
|
|
|
}
|