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: 
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.
Your returning an anonymous type from your linq query. Your view is expecting a list of type `tblParent`

Project your linq into the correct type and it should be fine.

At a glance it looks like 

```
select new { Email = x.ParentEmail, UserName = y.Username })

```

should be

```
select y

```