Selenium IDE - Extracting tag attribute

767 views
Skip to first unread message

Tam Norris

unread,
May 2, 2012, 12:53:37 AM5/2/12
to seleniu...@googlegroups.com
Hi,

I am using Selenium IDE to create a test that creates an insurance policy. After the policy has been finalised there are links to display the certificate of cover.

Which I can execute by using the command  click  |   //span[@id='r114282']. But the r number is unique for every policy. So I need to be able to extract it from the HTML below and store in a variable. I'm not sure what Selenium IDE command to use. I know I can use the storeText command with '//div[@class='section']/a[2]/span[@id]' in the target section to get the text inside the span tag, but its the id attribute r114282 that I want.

Do I use the storeAttribute command? I'm not sure how to write it.

<a class="external" target="_blank" href="/anzn/coc/r114282/certificate_of_currency.html">
        <span id="r114282"> Certificate of Currency - Home - 48 SHORTLAND STREET AUCKLAND CENTRAL AUCKLAND 1010 </span>
</a>

Any help would be greatly appreciated.

Thanks.

Tam.

Tarun Kumar

unread,
May 2, 2012, 1:20:50 AM5/2/12
to seleniu...@googlegroups.com
Try this -
 
<tr>
<td>storeAttribute</td>
<td>//div[@class='section']/a[2]/span@id</td>
<td>x</td>
</tr>
<tr>
<td>echo</td>
<td>${x}</td>
<td></td>
</tr> 

Here - //div[@class='section']/a[2]/span is your element locator and id is the attribute you want.

~tarun

Tam Norris

unread,
May 2, 2012, 9:13:25 PM5/2/12
to seleniu...@googlegroups.com
Thanks Tarun. That worked a treat.
Reply all
Reply to author
Forward
0 new messages