0

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" href="#">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?

1 Answer 1

3
 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 ?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.