Question

<a itemprop="director" href="/name/nm0000116/" onclick="(new Image()).src='/rg/title-overview/director-1/images/b.gif?link=%2Fname%2Fnm0000116%2F';">
James Cameron
</a> 

I want "James Cameron" as output, but unfortunately there is no function to get text like getText() etc. Please help me that how can I get it"

No correct solution

OTHER TIPS

There is Text property for that purpose:

IWebElement anchor = Driver.FindElementByTagName("a");
string innerText = anchor.Text;

I couldn't locate the method FindElementByTagName(). If you have trouble with that too, maybe this can work.

IWebDriver driver = new RemoteWebDriver(DesiredCapabilities.Firefox());
IWebElement anchor = driver.FindElement(By.TagName("a"));
string text = anchor.Text;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top