Unit testing with the WebBrowser control (LoadCompleted event doesn't fire) RRS feed

  • Question

  • (This question was originally posted in the WPF forum, but I was directed to this forum since the problem is specific to the unit test)

    I have posted a sample project that demonstrates a problem trying to unit test a wrapper control for a WebBrowser. The specific problem seems to be that the LoadCompleted event doesn't fire when I set the Source property on the WebBrowser in a unit test.


    The file is DemoWrapperBrowser.zip. It contains a VS 2012 solution with a WPF application project as well as a unit testing project. The target framework is 4.0.

    The folder contains a page named Demo.htm that should be copied to http://localhost. If you need to use another URL, you'll have to edit the project.

    You should see that the WPF application loads the Demo.htm file in the wrapped WebBrowser control and calls scripts to update the day of the month in the page. The unit test attempts to do the same thing, but the script is not invoked because the LoadCompleted event is never fired.


    Friday, February 7, 2014 1:33 PM