I need write function for take real top and left element in window. In DotNetBrowser we can take coordinates:
int Y = el.BoundingClientRect.Origin.Y;
int X = el.BoundingClientRect.Origin.X;
but its give no real coordinates if element into iframe.
I write some metod for taking real coordinates:
public int realY(IElement el)
{
IFrame f = el.Frame;
if (f.IsMain)
{
return el.BoundingClientRect.Origin.Y;
}
else
{
IElement fel = GetElementByAtrTag("iframe", "name", f.Name);
return el.BoundingClientRect.Origin.Y + fel.BoundingClientRect.Origin.Y;
}
}
but its not universal, becouse iframe not alredy have name (what I use in this method) or can be many parent iframe.
I try go other way, and for me need can take element parent iframe as IElement without id or name, having only Child IElement, example:
public IElement FindIframe(IElement el)
{
if (el.Parent.NodeName != "IFRAME")
{
return FindIframe((IElement)el.Parent);
}
else return (IElement)el.Parent;
}
this metod fail when up to parent iframe element, and his have NodeName - #document
I can take first parent iframe so:
IFrame parentElFrame = el.Frame;
but IFrame have not BoundingClientRect.
DotNetBrowser have IFrameElement and this element have BoundingClientRect, but I cant convert IFrame to IFrameElement
Where I can go?