How to associate the DOM container with the correct IE Form

Ask general questions here.
User avatar
Aracknid
Posts: 388
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

How to associate the DOM container with the correct IE Form

Post by Aracknid » Wed Jul 13, 2011 4:35 pm

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

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

Post by Support Team » Wed Jul 13, 2011 6:46 pm

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

User avatar
Aracknid
Posts: 388
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

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

Post by Aracknid » Wed Jul 13, 2011 7:13 pm

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

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

Post by Support Team » Thu Jul 14, 2011 2:37 pm

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