2

I'm having a hard time grasping the methods I see used to unit test UI functionality for a website (in this case, using ASP.NET MVC3). I tried using Watin, which, in a general sense what I want, with the exception of having to rely an actual instance of a web browser in order to make it work, as it complicates the whole process quite a bit, especially with CI.

In my ideal world this is how I imagine a test working:

  1. Pass a model to a view, get the output
  2. Populate a programmatic DOM with the view output
  3. The test would trigger DOM events to simulate clicking a button, for example, and verify that the DOM was manipulated in the expected way.

I realize this would require both a javascript engine and a DOM implementation either written in .NET or with .NET bindings. Does an obvious solution to my problem exist? If not, is there anything particularly dumb/wrong about the way I'd like to go about it?

1 Answer 1

2

What you are describing is known as a headless browser - XBrowser is one such effort, though the last check-in dates from April 2010.

Also see this post on using HtmlUnit in .NET development.

Sign up to request clarification or add additional context in comments.

3 Comments

I think you got me pointed in the right direction. I'm looking at phantomJS now to see if it's I could reasonably integrate.
@w.brian - Knowing what to search for is half the job these days ;)
Ain't that the truth! I'm really surprised a .NET solution doesn't already exist considering how insanely useful it would be. Perhaps I will look into cloning XBrowser and attempt to get it working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.