如何用selenium滚动页面

我正在使用FirefoxDriver webdriver。 在firefox窗口中加载的页面是一个大页面,我想使用selenium滚动该页面。

我想知道如何做到这一点。

谢谢。

如果你想使用selenium webdriver滚动firefox窗口,其中一种方法是在java代码中使用javaScript,向下滚动的javeScript代码如下:

WebDriver driver = new FirefoxDriver(); JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("window.scrollTo(0,Math.max(document.documentElement.scrollHeight," + "document.body.scrollHeight,document.documentElement.clientHeight));"); 

我想你应该做点什么

 driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") 

祝好运。

 page.driver.browser.mouse.move_to( find("element").native,100,100) 

使用此代码滚动单页

 Actions actions = new Actions(driver); actions.sendKeys(Keys.BACK_SPACE).perform();