Sleep 500 ms for screenshot.
This commit is contained in:
parent
bee21c138c
commit
34499d9eb3
|
|
@ -70,8 +70,9 @@ public class PlaywrightInstance : IDisposable
|
|||
{
|
||||
if (_contexts.ContainsKey(id))
|
||||
{
|
||||
await _contexts[id].Pages.Last().WaitForLoadStateAsync(LoadState.DOMContentLoaded);
|
||||
await _contexts[id].Pages.Last().WaitForLoadStateAsync(LoadState.NetworkIdle);
|
||||
var page = _contexts[id].Pages.Last();
|
||||
await page.WaitForLoadStateAsync(LoadState.DOMContentLoaded);
|
||||
await page.WaitForLoadStateAsync(LoadState.NetworkIdle);
|
||||
}
|
||||
await Task.Delay(100);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,12 +5,14 @@ public partial class PlaywrightWebDriver
|
|||
{
|
||||
public async Task<string> ScreenshotAsync(string conversationId, string path)
|
||||
{
|
||||
var bytes = await _instance.GetPage(conversationId)
|
||||
.ScreenshotAsync(new PageScreenshotOptions
|
||||
{
|
||||
Path = path,
|
||||
Animations = ScreenshotAnimations.Disabled
|
||||
});
|
||||
await _instance.Wait(conversationId);
|
||||
var page = _instance.GetPage(conversationId);
|
||||
|
||||
await Task.Delay(500);
|
||||
var bytes = await page.ScreenshotAsync(new PageScreenshotOptions
|
||||
{
|
||||
Path = path
|
||||
});
|
||||
|
||||
return "data:image/png;base64," + Convert.ToBase64String(bytes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class ScreenshotFn : IFunctionCallback
|
|||
var path = webDriverService.GetScreenshotFilePath(message.MessageId);
|
||||
|
||||
message.Data = await _browser.ScreenshotAsync(convService.ConversationId, path);
|
||||
message.Content = "Took screenshot completed";
|
||||
message.Content = "Took screenshot completed. You can take another screenshot if needed.";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class ScrollPageFn : IFunctionCallback
|
|||
var agent = await agentService.LoadAgent(message.CurrentAgentId);
|
||||
|
||||
message.Data = await _browser.ScrollPageAsync(new BrowserActionParams(agent, args, convService.ConversationId, message.MessageId));
|
||||
message.Content = "Scrolled";
|
||||
message.Content = "Scrolled. You can scroll more if needed.";
|
||||
|
||||
var webDriverService = _services.GetRequiredService<WebDriverService>();
|
||||
var path = webDriverService.GetScreenshotFilePath(message.MessageId);
|
||||
|
|
|
|||
Loading…
Reference in a new issue