自动化测试中的滚动
2018-02-27 14:49 钱先生 阅读(322) 评论(0) 编辑 收藏 举报1. 滚动一定像素的距离
1 JavascriptExecutor js = (JavascriptExecutor) driver; 2 3 js.executeScript("window.scrollTo(100,600)");
2. 滚动到指定元素
1 JavascriptExecutor js = (JavascriptExecutor) driver; 2 3 js.executeScript("arguments[0].scrollIntoView(true)", webElement);
3. 滚动到页尾
1 JavascriptExecutor js = ((JavascriptExecutor) driver); 2 js.executeScript("window.scrollTo(0, document.body.scrollHeight);"); 3
4. 滚动到页头
1 JavascriptExecutor jse = ((JavascriptExecutor) driver); 2 jse.executeScript("window.scrollTo(0, -document.body.scrollHeight);"); 3 4 //尚未验证