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);