Parsing xpath results in selenium ide



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

    *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(@emran     <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')][] not found.

    Any idea what I'm doing wrong ?



  • 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.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2