将页面滚动条滑动到最下方
//滚动到页面的最下端 public void bottomOfPage( WebDriver driver ) { ((JavascriptExecutor)driver).executeScript("window.scrollTo(0,document.body.scrollHeight)"); }
2.将滚动条移动到指定元素是位置
// 滚动到指定元素位置 public void moveToElementPage(WebDriver driver,WebElement element ) { ((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView();",element); }
3.将滚动条移动指定元素
public void moveelem( WebDriver driver) { ((JavascriptExecutor)driver).executeScript("window.scrollBy (0,800)");//向下滑动800 //向上就是(800,0) }
还没有评论,来说两句吧...