📜  向上滚动 - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:29.348000             🧑  作者: Mango

代码示例1
Selenium does not have a method for scrolling
but there are some ways to scroll:
#1 ->=moveToElement= coming from Actions class
   will scroll down and up to given web element
#2 Using JSExecutor: We can inject JavaScript
   code in our Java+Selenium code using JSExecutor
   which helps us scroll up, down, left, right.
   We need to create instance of JS executor,
   then cast our driver type of it.
WebDriver driver = new ChromeDriver(); 
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("scroll(0, 250);"); Scroll Down
jse.executeScript("scroll(0,-250);"); Scroll Up