单击所有div layers insight div

时间:2016-09-02 08:57:24

标签: java selenium selenium-webdriver

我有这个html代码,我想用Selenium进行测试:

http://pastebin.com/LX5URz53

我想得到所有div层洞察div boxes我怎么能这样做?

RemoteWebDriver driver = BrowserFactory.getDriver(" chrome"," C:\ Program Files(x86)\ Google \ Chrome \ Application \ chromedriver.exe");

    driver.get("http://jenkins.mws.com:8080");

    driver.switchTo().frame("iwg-game-full");

    WebDriverWait waitPage = new WebDriverWait(driver, 20);

    WebElement element = new WebDriverWait(driver, 20).until(steadinessOfElementLocated(By.id("ready")));

    element.click();

    if (element.isDisplayed())
{
    System.out.println("Play button is displayed");

    TimeUnit.SECONDS.sleep(5);

    List<WebElement> childs = driver.findElements(By.xpath("div[id='boxes'] div"));

    for (int i = 0; i < childs.size(); i++)
    {
        WebElement get = childs.get(i);

        get.getText();
        System.out.println(">>>>> getText " + get.getText() + " " + get.getTagName());
    }
}

1 个答案:

答案 0 :(得分:1)

"//div[@id='boxes']//div"方法中使用xpath - "div[id='boxes'] div"或css driver.findElements(By.....)