0

enter image description hereIts name of tab. I have tried by Link-text but it's not working.

I have tried d.findElement(By.linkText("Clauses")).click(); It shows error

Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"link text","selector":"Clauses"}

enter image description here

  • 1
    //span[contains(text(), 'Clause')], can you try this XPath please, Is there a chance the element to be in iFrame. – Nikolay Barakov Jan 7 at 10:38
  • I think you need to consider the selector you are using. You have tried with class 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 try d.findElement(By.className("clauses")).click() to click on Clauses or d.findElement(By.className("myAssignedRequests")).click() to click on My Assigned Requests – Shamanth Jan 7 at 11:04
  • Thank you all for your help! It worked .It was iframe. – Pooja Jan 8 at 8:58
1

Whole web page is frame. So first I switched to frame & then performed actions

d.switchTo().frame("frame-8_SNb34A224IASwxX0yc");
d.findElement(By.xpath("//[@id='tabviewMainContainerLexApp']/div/ul/li[11]/a/span")).click(); //click on tab using X-path
0

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.

0

Why dont you simply select the anchor tag

driver.findElement(By.xpath("//a[contains(.,'Clauses')]")).click();
  • Thank you all for your help! It worked .It was iframe – Pooja Jan 8 at 8:59

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.