-1

I've read all the posts related here and in google and none helped me with my issue, im trying to read with selenium the li element from a website, i basically need all the li childs in lists.

the code i wrote in java:

    List<WebElement> elements = driver.findElements(ByTagName.tagName("form"));
    element1 = elements.get(0).findElement(ByTagName.tagName("iframe"));
    driver.switchTo().frame(element1);
    element2 =  driver.findElement(By.xpath("//div[@id='Scroller']//ul"));
    childs = element2.findElements(ByTagName.tagName("div"));

    driver.close();

and the returned value for childs is empty for some reason. can anyone help me please? ive tried xpath, css selector and tagnames, nothing helped.

4

2 回答 2

0

我设法看到了你的 HTML 图片:

http://i.stack.imgur.com/mvVzW.png

一个小提示,只需将 HTML 复制/粘贴到您的问题中,效果会更好,而且您不需要任何声誉。

无论如何,如果你正在做的只是试图抓住diveach 下的 's li,你可以使用 CSS 选择器来做到这一点:

div#Scroller > ul > li > div

如果没有,请告诉我们您想要得到什么 div

于 2013-10-30T09:36:07.187 回答
0

您可以尝试将所有 li 项目作为循环中的数组读取。

//div[@id="Scroller"]/ul[0]/li



//div[@id="Scroller"]/ul[0]/li[1]
于 2013-10-29T17:22:08.973 回答