【发布时间】:2016-07-07 06:32:12
【问题描述】:
我正在尝试使用 selenium webdriver 做一个示例程序。我正在使用 Selenium-java-2.53.1 中的库。
这是我的示例程序
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
public class ScrollWebPage {
WebDriver driver;
String URL="https://www.gmail.com";
@BeforeClass
public void setUp(){
driver = new FirefoxDriver();
driver.get(URL);
driver.manage().window().maximize();
}
@Test(priority=1)
public void scrollingToBottom(){
((JavascriptExecutor) driver).executeScript(URL, "window.scrollTo(0,document.body.scrollHeight)");
}
@AfterClass
public void tearDown(){
driver.quit();
}
}
页面正在打开,但无法向下滚动。 executeScript() 似乎有问题
请帮忙
【问题讨论】: