0

I am trying to get a value from a nested div in a web page using Selenium IDE where class names are repeated but contain unique strings, such as the structure below, but am having no luck.

<div class='ClassName'>
    <div class="col_Num">1 </div>
    <div class="col_Val">5.00 </div>
</div>

<div class='ClassName'>
    <div class="col_Num">2 </div>
    <div class="col_Val">2.00 </div>
</div>

How do I get the value of 'Col_Val' from only the div that contains "col_Num = 1"? (the value 5.00 should be returned and saved to a variable)

Thanks, J

2
  • Do you want to display 'col_Val' in both the div tags or only from first div tag???? Commented Jun 18, 2015 at 4:39
  • try this: stackoverflow.com/help/how-to-ask tell us what you tried, and show exactly what your desired output is Commented Jun 18, 2015 at 6:25

2 Answers 2

1

From your question, it seems that you want to be able to store the column value based on the number you input. The best way to do this would be

<tr>
    <td>storeText</td>
    <td>css=div:contains("1")+[class=col_Val]</td>
    <td>value</td>
</tr>

Which will store the column value located immediately after the div containing the value you input (in this case 1)

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

Comments

0

In Selenium IDE enter as: Command | Target | Value

storeText | //div[@class='col_Num' and contains(text(), '1')]/following-sibling::div | value
    echo | ${value}

Output is:

[info] Executing: |storeText | //div[@class='col_Num' and contains(text(), '1')]/following-sibling::div | value |  
[info] Executing: |echo | ${value} | |  
[info] echo: 5.00  
[info] Test case passed

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.