ScrollPage
This commit is contained in:
parent
bf84d4a87a
commit
780718ef97
|
|
@ -12,12 +12,20 @@ public partial class PlaywrightWebDriver
|
|||
if (args.Direction == "down")
|
||||
{
|
||||
// Get the total page height
|
||||
int scrollY = await page.EvaluateAsync<int>("document.body.scrollHeight");
|
||||
int scrollY = await page.EvaluateAsync<int>("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<int>("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<int>("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<int>("document.body.scrollHeight");
|
||||
|
||||
// Scroll to the top
|
||||
await page.Mouse.WheelAsync(0, -scrollY);
|
||||
}
|
||||
else if (args.Direction == "left")
|
||||
{
|
||||
await page.EvaluateAsync(@"
|
||||
|
|
|
|||
Loading…
Reference in a new issue