diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.ScrollPage.cs b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.ScrollPage.cs index c50bf48b..48538ce8 100644 --- a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.ScrollPage.cs +++ b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.ScrollPage.cs @@ -12,12 +12,20 @@ public partial class PlaywrightWebDriver if (args.Direction == "down") { // Get the total page height - int scrollY = await page.EvaluateAsync("document.body.scrollHeight"); + int scrollY = await page.EvaluateAsync("window.screen.height"); - // Scroll to the bottom + // Scroll a page down await page.Mouse.WheelAsync(0, scrollY); } else if (args.Direction == "up") + { + // Get the total page height + int scrollY = await page.EvaluateAsync("window.screen.height"); + + // Scroll a page up + await page.Mouse.WheelAsync(0, -scrollY); + } + else if (args.Direction == "bottom") { // Get the total page height int scrollY = await page.EvaluateAsync("document.body.scrollHeight"); @@ -25,6 +33,14 @@ public partial class PlaywrightWebDriver // Scroll to the bottom await page.Mouse.WheelAsync(0, -scrollY); } + else if (args.Direction == "top") + { + // Get the total page height + int scrollY = await page.EvaluateAsync("document.body.scrollHeight"); + + // Scroll to the top + await page.Mouse.WheelAsync(0, -scrollY); + } else if (args.Direction == "left") { await page.EvaluateAsync(@"