1

Here is my element

<td>
<div class="linkButton" onclick="window.open('../../Report/Reports/ViewReport.aspx?reportName=Revenue.Report','Report1','scrollbars=1,resizable=yes,width=800,height=600');">Revenue Report</div>
</td>

I have tried the following XPaths:

//td[contains(text(), 'Revenue Report')]
//*[contains(@onclick, 'Revenue.Report')]

Both fail with "OpenQA.Selenium.NoSuchElementException: no such element: Unable to locate element"

Are there other options for selecting this web element?

João Farias
11.2k2 gold badges21 silver badges41 bronze badges
asked Mar 12, 2021 at 22:18

2 Answers 2

1

There're usually more options, e.g.:

// CSS
currentDriver.FindElement(By.CssSelector("td > div.linkButton"));
currentDriver.FindElement(By.CssSelector("div.linkButton"));
// xPath
currentDriver.FindElement(By.XPath("//div[text()='Revenue Report']"));

Another problem might be with element visibility, you can search this site for more information on that. Selenium WebDriver with C# binding doesn't have any retry policy, so you basically need to wait for elements and their states.

answered Mar 12, 2021 at 23:14
1
//div[contains(text(), 'Revenue Report')]
//td[contains(string(), 'Revenue Report')]

use any of the above locator, the text is inside div tag and not td.

answered Mar 13, 2021 at 16:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.