selenium webdriver 屏幕滚动



      //山寨法
    String setscroll = "document.documentElement.scrollTop=100"; JavascriptExecutor jse=(JavascriptExecutor) driver; jse.executeScript(setscroll);

 

    //专业法
WebElement target = driver.findElement(By.xpath(xpath表达式));//如:".//*[@id='count2']/table[1]/tbody/tr[5]/td/div/table"
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView();", target);

 

posted @ 2013-08-25 13:40  苦逼IT男  阅读(3144)  评论(0编辑  收藏  举报