Java Web驱动程序中的页面滚动

Java Web驱动程序中的页面滚动,java,selenium,selenium-webdriver,Java,Selenium,Selenium Webdriver,如何使用webdriver直接滚动页面。我知道如何使用javascript执行器滚动。我的问题是,不使用java脚本可以完成吗 对于java脚本,我使用了以下内容: JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript("window.scrollBy(0,450)", ""); Actions actions = new Actions(driver); actions.keyDown(Keys.CONT

如何使用webdriver直接滚动页面。我知道如何使用javascript执行器滚动。我的问题是,不使用java脚本可以完成吗

对于java脚本,我使用了以下内容:

JavascriptExecutor jsx = (JavascriptExecutor)driver;
jsx.executeScript("window.scrollBy(0,450)", "");
Actions actions = new Actions(driver);
actions.keyDown(Keys.CONTROL).sendKeys(Keys.END).perform();
//OR
actions.sendKeys(Keys.chord(Keys.CONTROL, Keys.END)).perform();
Actions actions = new Actions(driver);
actions.sendKeys(Keys.SPACE).sendKeys(Keys.SPACE).sendKeys(Keys.SPACE).perform();

若要滚动到页面末尾,可以执行以下操作:

JavascriptExecutor jsx = (JavascriptExecutor)driver;
jsx.executeScript("window.scrollBy(0,450)", "");
Actions actions = new Actions(driver);
actions.keyDown(Keys.CONTROL).sendKeys(Keys.END).perform();
//OR
actions.sendKeys(Keys.chord(Keys.CONTROL, Keys.END)).perform();
Actions actions = new Actions(driver);
actions.sendKeys(Keys.SPACE).sendKeys(Keys.SPACE).sendKeys(Keys.SPACE).perform();
如果要逐点滚动,可以执行以下操作:

JavascriptExecutor jsx = (JavascriptExecutor)driver;
jsx.executeScript("window.scrollBy(0,450)", "");
Actions actions = new Actions(driver);
actions.keyDown(Keys.CONTROL).sendKeys(Keys.END).perform();
//OR
actions.sendKeys(Keys.chord(Keys.CONTROL, Keys.END)).perform();
Actions actions = new Actions(driver);
actions.sendKeys(Keys.SPACE).sendKeys(Keys.SPACE).sendKeys(Keys.SPACE).perform();
但是,如果您想滚动到页面上的某个特定点,Java脚本是您最好的选择。

这能回答这个问题吗??