Search code examples
watirwebrat

How to use Watir to find a specific link when all the links have the same display text?


The links are wrapped in a span:

<span class='editbio'>
<a href="/experts/3987/edit">Edit</a>
</span>
...
<span class='addbio'>
<a href="/experts/3987/edit">Edit</a>
</span>

Solution

  • How about something like

    browser.span(:class, "editbio").link(:text, "Edit")
    

    to get the first link vs

    browser.span(:class, "addbio").link(:text, "Edit")
    

    for the second link?

    You can get a list of elements and tags you can use at Watir: Methods supported by Element.