I have the following HTML code:
<td class="gnb_menu" id="MAIN_04" name="MAIN_04" style="width:100px;text-align:center;">
<span style="cursor:pointer;" onclick="javascript:movePage('MAIN_04','/basis/menuServlet.do?method=getMenuUrl','body','Y')">
<nobr>Business</nobr>
</span>
</td>
I am trying to get the XPath of the span tag. I am using Selenium and have tried this:
cd.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
var d = cd.FindElementByXPath("//td[@id='MAIN_04']/span[@style='cursor:pointer;']");
d.Click();
But keep running into the error: "OpenQA.Selenium.NoSuchElementException has been thrown"
because it is unable to locate the element/no such element.
I have tried many different XPath (//*[@id='MAIN_04']/span)
,(//td[@id='MAIN_04']/span)
, etc. but still cannot get this right. I even tried to take out the implicit wait because I thought it was a timeout error... I don't know.
PLEASE HELP I am new to this and I'm so confused. Thank you!