How to test Web UI of a Web Browser control inside a WinForms application?

2k views Asked by At

We have a web application that can be tested using Selenium, but that's not enough because the web application will be used inside a WinForms application using the Web Browser control.

The WinForms app interacts with the content of the page hosted inside the Web Browser Control and viceversa.

We have tests on other layers like services, but we need to find a way to test the WinForms UI that interact with the Web Browser control.

Any suggestion?

2

There are 2 answers

2
Myles McDonnell On BEST ANSWER

What you need is a WinForm test automation. A friend of mine blogged about this recently; http://matthewskelton.wordpress.com/2012/01/08/test-automation-tools-for-winforms-desktop-applications/

0
Matthew Skelton On

In addition to the link which Myles kindly provided, I also blogged specifically about calling the WebBrowser control from C# WinForms applications here:

http://matthewskelton.wordpress.com/2007/04/21/calling-javascript-from-c/

Specifically, you can use Type.InvokeMember() to call JavaScript from C#.

In terms of testing this, I suppose you'd need to drop a JavaScript listener/logger into the DOM, hooking it onto a low-level event or prototype, and then log out to the JavaScript console.