如何使用Selenium Webdriver滚动面板

时间:2014-04-25 06:26:38

标签: selenium scroll webdriver

我想使用selenium webdriver向下移动面板。

           public void AddCode()

           {

             try
             {
                   getChromeDriver().findElementByClassName("odd").click();
        Thread.sleep(5000);

          getChromeDriver().manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);

                       /*I want to move down panel here.

                         Panel tag : <div id="icd9-tab-data">

                         Scrollbar tag : <div class="mCSB_dragger_bar" style="position: relative; line-height: 505px;"></div>*/

        /* "add-ic9-diagnosis-code" link has been displayed in bottom of panel, so not able to click on this link without scrolling panel. */
        getChromeDriver().findElement(By.id("add-icd9-diagnosis-code")).click();
        Thread.sleep(3000);

    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}

我想使用selenium webdriver向下移动面板。

面板标签:

滚动条标记:

1 个答案:

答案 0 :(得分:1)

你想要这样的东西:

((JavascriptExecutor)driver).executeScript("window.scrollBy(0,10);");
  

//测试此代码以滚动浏览器滚动条

或者您可以使用此代码聚焦(移动到)元素:

Actions action = new Actions(driver);
action.moveToElement(WebElement).perform();

如果两者都不符合您的要求,请详细说明您的要求。

相关问题