Question: **Test Environment - Working on writing tests in Selenium web driver in C#.net. And running them via NUnit.**
The base url - <http://localhost/OnlineTest/login.aspx>
Inside of this there is an iframe, inside of which there is a grid,
Here is what I want to automate. 

```
• Go to the Grid
• Click on an image. 
• It opens new window(like a pop up). 
• Go to that window .
• Verify its text & click Close button.

```

I am not able to find a way to go to another window via code.

This is what I have tried - 
IWebElement element=  
driver.SwitchTo().Window("ViewQuestionPreview.aspx?QsnId=Qsn16").FindElement(By.Id("btnClose"));

I have also changed the URL to different combinitions like 

* "/ViewQuestionPreview.aspx?QsnId=Qsn16"
* "http://localhost/OnlineTest/ViewQuestionPreview.aspx?QsnId=Qsn16"
* "/OnlineTest/ViewQuestionPreview.aspx?QsnId=Qsn16"
* "OnlineTest/ViewQuestionPreview.aspx?QsnId=Qsn16"

***Error - No such Window found. NoSuchWindowException***

would appreciate of someone can help.

**Tahir**

Answer: 
Your view expects tblParent but you are passing it the joined table.

You need to create a ViewModel, join your tables there and change your view to expect the ViewModel rather than tblParent.

Thre are loads of examples. Here's one: [ASP.NET MVC ViewModel Pattern](https://stackoverflow.com/questions/1361092/asp-net-mvc-viewmodel-pattern)

I hope this helps

Davy
In the view file, you require a model of type IEnumerable of ETMS.Models.DB.tblParent, and in the controller, you pass in **members.ToList()**, you have to change either one to make it match.

You can create a viewmodel like this

```
public Class Client 
{ 
   public string Email {get;set;}
   public string UserName   {get;set;}
}

```

And return a list of this instead of anonymous type in your controller action, and you will define IEnumerable of Client type in your view.