Page 1 of 1

How to associate the DOM container with the correct IE Form

Posted: Wed Jul 13, 2011 4:35 pm
by Aracknid
I'm trying to write code to work with an already running IE window. The issue I'm having is that there might be multiple IE windows open, and I need to make sure I connect to the correct one. The only way I know is by looking at the DOM container for the correct IE window, and by checking the PageUrl for this DOM object (each running IE window I want to work with has a unique session number as part of the URL, which I know).

So, I wrote some code to get all the IE forms into a collection and I'm iterating through them, but how do I know which DOM container goes with the form? I cannot go by Caption, since they are all the same.

Thanks,

Aracknid

Re: How to associate the DOM container with the correct IE Form

Posted: Wed Jul 13, 2011 6:46 pm
by Support Team
Could the WebDocument.Browser property be the thing you are searching? That property returns the Form adapter corresponding to the web document. So you can get the browser form for a DOM directly using that property.

Regards,
Alex
Ranorex Team

Re: How to associate the DOM container with the correct IE Form

Posted: Wed Jul 13, 2011 7:13 pm
by Aracknid
What you've suggested is backwards to what I was thinking. Maybe I can try it the other way around and see if it works for me...

When I'm in the Spy window, I see the IE Forms and the DOM objects (which have a preferredCapability as a WebDocument). I also found that I can drill down into the Form and find the DOM in the 'Shell DocObject View' container of the Element 'Frame Tab'. But I just wanted to find the DOM item off the root that went with the Form since I figured it was easier than drilling down into the Form.

Aracknid

Re: How to associate the DOM container with the correct IE Form

Posted: Thu Jul 14, 2011 2:37 pm
by Support Team
Aracknid wrote:I also found that I can drill down into the Form and find the DOM in the 'Shell DocObject View' container of the Element 'Frame Tab'.
Right, the DOM element in the top level of the Ranorex element tree is basically just a copy of the DOM within the form. The two corresponding DOM elements (top level and underneath "Shell DocObject View") are identical, so you can use either one.

Regards,
Alex
Ranorex Team