标签:bottom script document element path except 滚动条 dex [1]
/**
* 滚动条滚到最下方,和滚到指定位置
*/
@Test(priority =1 )
public void scrollingToBottomo(){
//使用JavaScript的scrollTo函数和document.body.scrollheihgt参数
//将页面的滚动条滑到页面的最下方
((JavascriptExecutor) driver)
.executeScript("window.scrollTo(0, document.body.scrollHeight)");
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Test(priority = 2)
public void scrollingToElement(){
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//进入搜索视频页面中的ID值为main_frame的frame页面
//driver.switchTo().frame("main_frame");
//定位签文字为“电影”
WebElement element = driver.findElement(By.xpath(".//*[@id=‘container‘]/div[2]/div[1]/div[2]/div[1]/h3/a"));
//使用JavaScript的scrollIntoView()函数将滚动条滑动到页面的制定元素位置
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", element);
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
标签:bottom script document element path except 滚动条 dex [1]
原文地址:http://www.cnblogs.com/hxm154/p/6165231.html