Selenium web test: get a list of links names from html
How do I fill map by a list of links names from a html code. clearly, I've this code HTML:
<div id="element-list">
<dl id="element-template" class="element">
<dd class="element element-1-0">
<a class="element-name" hre开发者_JAVA技巧f="#">TEXT1</a>
</dd>
<dd class="element element-1-0">
<a class="element-name" href="#">TEXT2</a>
</dd>
<dd class="element element-1-0">
<a class="element-name" href="#">TEXT3</a>
</dd>
</dl>
I would like to recover in a map java Text1, Text2, Text3.
I get the first link (text1) in this manner:
String elmt = selenium.getText("css=a.element-name");
and this is normal, but I need to check all elements.
Could anyone help me by telling me the best way to do that?
int count = selenium.getXpathCount("//a[@class='element-name']").intValue();
for(int i =1 ; i <= count ; i ++){
System.out.println(selenium.getText("//dd["+i+"]/a"));
}
Does this help ?
精彩评论