1

I'm trying to get a list of all the links that follow a certain rule ( their href is Downloads.aspx?<somestring> )

*Note: I'm using Selenium IDE, the Firefox plugin for this.

In order to get the links, I use this code :

<tr>
    <td>open</td>
    <td>/DownloadsHome.aspx</td>
    <td></td>
</tr>
<tr>
    <td>storeXpathCount</td>
    <td>xpath=//a[contains(@href,'Download.aspx')]</td>
    <td>links</td>
</tr>
<tr>
    <td>echo</td>
    <td>links : ${links}</td>
    <td></td>
</tr>
<tr>
    <td>storeAttribute</td>
    <td>//a[contains(@href,'Download.aspx')][1]@href</td>
    <td>tmpHref</td>
</tr>
<tr>
    <td>echo</td>
    <td>${tmpHref}</td>
    <td></td>
</tr>
<tr>
    <td>storeAttribute</td>
    <td>//a[contains(@href,'Download.aspx')][3]@href</td>
    <td>tmpHref2</td>
</tr>
<tr>
    <td>echo</td>
    <td>${tmpHref2}</td>
    <td></td>
</tr>

Now, the result for ${links} is 301 and I get the correct result for ${tmpHref} but for anything other than //a[contains(@href,'Download.aspx')][1]@href I get [error] Element //a[contains(@href,'Download.aspx')][<number>] not found.

Any idea what I'm doing wrong ?

  • 2 questions: 1. Is it supposed to be Download.aspx or Downloads.aspx? 2. Have you tried [first()], [last()], and [position()=3]? – rishimaharaj Mar 18 '14 at 3:12
1

This is a pretty old answer. I would use Selenium Builder instead. The Selenium project is in the process of replacing Selenium IDE with Selenium Builder.

Most likely, after recording your script, you might want to make minor edits to the script by hand to get it working the way you want it to.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.