Question: I'm getting started coding tests using watiN and I'm having trouble simulating a user pressing a key when a SelectList is in focus. This is to test that a client-side JavaScript function that is triggered by the OnKeyUp event on the SelectList runs correctly.

How can I simulate a user giving focus to the SelectList and pressing the 'o' key on their keyboard? 

I'm using the latest WatiN release and am doing a C# unit test in VS2008. I've coded

```
ie = new IE(myTestPageURL);
SelectList mySelect = ie.SelectLists[0];
mySelect.Focus();
mySelect.KeyPress('o');
Assert.IsTrue(mySelect.SelectedItem != null);

```

My select list has an option in it called "One", so pressing the 'o' key should result in it being the selected item. However, nothing is happening when the keyPress call is made except that the SelectList loses focus, and my test fails.

Answer: 
You should actually add the control to a page and execute the page:

```
    var page = new FormlessPage();
    var ctrl = (UserControl)page.LoadControl("~/EmailTemplates/OrderConfirmation.ascx");

    page.Controls.Add(ctl);
    StringWriter writer = new StringWriter();
    HttpContext.Current.Server.Execute(page, writer, false);
    return writer.ToString();

```

Formless page simply looks like:

```
public class FormlessPage : Page
{
    public override void VerifyRenderingInServerForm(Control control)
    {
    }
}

```

It allows your control to have input elements without a `<form>` wrapper.

This method will call your page lifecycle methods and bind up your form elements nicely.
You could have a Public function (aka ProcessLoad), instead of Page\_Load function and call it immediately after loading the control. This way you can pass parameters to your UserControl as well.