You can use byXpath
to find element using xPath expressions. To get the link you should use the following:
//li[@class='uwa-tab clauses']/a[@href='#clauses']
To go further to get the span
:
//li[@class='uwa-tab clauses']/a[@href='#clauses']/span[.='Clauses']
or a simplified one without the classes
:
//li/a/span[.='Clauses']
If you want to find the link (<a>..</a>
) and you want to filter only by the title you could use:
//li/a/span[.='Clauses']/..
This one locates the span
by its text and then steps back to its parent by the /..
.
Also there are many more possibilities, this locator table cheat-sheat summarizes them quite well.
title
which may be present in other parts of the DOM and so it may not work as expected. As suggested by others, try css or xpath selectors. You can tryd.findElement(By.className("clauses")).click()
to click on Clauses ord.findElement(By.className("myAssignedRequests")).click()
to click on My Assigned Requests