I could write my harness using C++ and then call the mshtml.dll and shdocvw.dll functions directly. But this is difficult. An easier approach is to write a test harness using C#. The C# code uses the "P/Invoke" mechanism to call into the Win32 libraries — much easier. Launching the Internet Explorer browser looks something like this:
SHDocVw.InternetExplorer ie = null;
Process p = Process.Start("iexplore.exe", "about:blank");
if (p == null)
throw new Exception("Could not launch IE");
Console.WriteLine("Process handle = " +
After you load the application under test, you can manipulate it like this:
Console.WriteLine("Clicking search button");
HTMLInputElement butt =
Conceptually, the technique is pretty easy but there are a lot of tricky details. For example, in the code snippet above, the WaitOne() method call is a key trick which halts the test harness thread of execution until after the click operation completes. You can’t pause using something like Thread.Sleep(2000) because there’s really no way to tell how long to pause.
I devote an entire chapter of my book ".NET Test Automation Recipes" to all the details of writing low-level Web application UI testing. See http://www.amazon.com/gp/product/1590596633/qid=1150213081/sr=2-1/ref=pd_bbs_b_2_1/103-1065536-4310244?s=books&v=glance&n=283155 for details.