user1763328
user1763328

Reputation: 311

Getting value from div which contains exact string using Selenium IDE

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

Upvotes: 0

Views: 1279

Answers (2)

Jsmith2800
Jsmith2800

Reputation: 1113

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)

Upvotes: 1

W&#252;rgspa&#223;
W&#252;rgspa&#223;

Reputation: 4820

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

Upvotes: 0

Related Questions