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"}
3 Answers 3
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
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.
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 iframePooja– Pooja2019年01月08日 08:59:24 +00:00Commented Jan 8, 2019 at 8:59
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