Question: I'm using Selenium 2 and I want to click an 'invite' link for Name3. How can I do that?

here is the html code:

```
<ul>
    <li>
        <label for="511565484">
        <img src="pic1">Name1</label>
        <a class="button_green sendInvite" href="javascript:;" title="Invite">Invite</a>
    </li>

    <li>
        <label for="535963597">
        <img src="pic2">Name2</label>
        <a class="button_green sendInvite" href="javascript:;" title="Invite">Invite</a>
    </li>

    <li>
        <label for="561708219">
        <img src="pic3">Name3</label>
        <a class="button_green sendInvite" href="javascript:;" title="Invite">Invite</a>
    </li>
</ul>

```

Answer: 
Seems likely it can only be done with XPath:

```
//label[text()='Name3']/following-sibling::a

```
element2 = driver.findElement(By.xpath("//img[()text='Name3']/a"));
element2.click();