tags:

views:

23

answers:

1

Hi.

I'm using Watin and Nant to create unit tests for my web site.

I want to know the way how to test content of the popup IE window. That window is opening when user clicks on the link that has target="_blank", like on the example below

<p>
... receives oversight and governance from the 
<a target="_blank" href="ihealth.html">iHealth Alliance</a>,
a not-for-profit organization ....  </p>

Here is the code I'm trying to use:

_ie = new IE(SITE_ROOT);
_ie.Link(f => f.Text == "iHealth Alliance").Click();
//here i need to enter something to check if popup window has appropriate title
//something like Assert.AreEqual("My page title to test", _ie.ChildWindows[0].Title)

As i can see, Watin's API allows to search for controls within one IE window, but, for some reason, it does not track for new windows that is opening as result of working primary window. There definitely should be something like ChildWindows or PopupWindows collections

Can you suggest me the way of how i can do that?

Thank you!

+1  A: 

I found the solution for this thing

Browser.AttachTo() allows to attach to any IE window and it lets to search by dozen criteries So, my code will look like:

_ie = new IE(SITE_ROOT);
_ie.Link(f => f.Text == "iHealth Alliance").Click();

Assert.IsNotNull(Browser.AttachTo<IE>(Find.ByTitle("My page title to test")));
Andrey Tagaew