1、以下只适合IE、Firefox:
1 el=browserCore.findElement(By.xpath(xpath));2 javaScriptExecutor.executeScript("arguments[0].scrollIntoView();", el); ?3 javaScriptExecutor.executeScript("arguments[0].scrollIntoView(true);", el);4 pause(stepInterval);
2、以下IE、Firefox、Chrome都适用:
1 el=browserCore.findElement(By.xpath(xpath)); 2 //将页面滚动条拖到指定元素处3 javaScriptExecutor.executeScript("document.getElementsByClassName(‘"+className+"‘)[0].scrollTop=100000");4 pause(stepInterval);
JS实现Selenium下拉滚动条到指定元素
原文地址:https://www.cnblogs.com/helenqueen/p/8241211.html