Can't find element

Viewed 273

I need to find the a href element and return its contents.

Here are the contents in the source:

<div id="responseDiv" style="background-color:#EBECED;width: 450px;">
<iframesrc="/iframe.asp" width="575" height="120" frameborder="0" 
marginwidth="1" marginheight="1" scrolling="no">
#document
<html>
<head> </head>
<body marginwidth="1" marginheight="1">
<font size="3" style = "letter-spacing: 0pt" color="#336699" face="Arial"
<a href="blablabla?subject=blebleble" target="_blank">merkl@gmail.com</a>
</font>
</body>
</html>
</iframe>
</div>

Tried printing outerHTML of the Div, which is the only element I can find:

IWebElement pisso = driver.FindElement(By.XPath("//*[@id="responseDiv"]"));
string outerHTML = pisso.GetAttribute("outerHTML");

But it doesn't return the href contents, only this:

<div id="responseDiv" style="background-color:#EBECED;width: 450px;">

<iframe src="/iframe.asp" width="575" height="120" frameborder="0" marginwidth="1" marginheight="1" scrolling="no">
  &lt;p&gt;Your browser does not support iframes.&lt;/p&gt;</iframe>

</div>

I've tried finding the href element directly but it can't find it, CssSelector as:

IWebElement pisso = driver.FindElement(By.CssSelector("body > font > a"));

Also tried XPath as:

 IWebElement pisso = driver.FindElement(By.XPath("/html/body/font/a"));
3 Answers
Related