这里面主要由链接(http://selenium-tutorial.blogspot.sg/2013/02/scroll-page-webdriver.html)整理过来,主要回答了如何用webdriver来滚动页面,滚上滚下,滚到指定元素以及怎么识别滚动条等。
1. 利用selenium中的focus(locator)函数实现(Link)
@Test
public void testFocus() throws Exception {
selenium.open("/");
selenium.windowMaximize();
selenium.type("q", "selenium wiki");
selenium.click("btnG");
//Waiting for an element
for (int second = 0;; second++) {
if (second >= 60) fail("timeout");
try {
if (selenium.isElementPresent("link=Selenium Overview - Wiki - Liferay.com"))
break;
} catch (Exception e) {}
Thre