I have been banging my head on this for the better part of a day; I need to count the number of childNodes in a parent div. It basically is acting like a list and each childNode is a row I want to count. The html looks like:
div<@class="list ">
div<@id="list-item-01">
div<@id="list-item-02">
div<@id="list-item-03">
div<@id="list-item-04">
div<@id="list-item-05">
...
</div>
My primary approach has been to use the getEval()
function in Selenium using some javascript.
examples that have failed:
String locator = "xpath=//div[contains(@class,'list')]";
String jscript = "var element = this.browserbot.findElement('"+locator+"');";
jscript += "element.childNodes.length;";
String locator = "xpath=//div[@class='list']";
String jscript = "var element = this.browserbot.findElement('"+locator+"');";
jscript += "element.childNodes.length;";
Now I know the element is there and my xpath is correct because I have tried using .isElementPresent
and that returns true. So something is funky with Selenium and divs.
I also poked around with document.evaluate()
as my javascript command but that proved equally fruitless.