dinsdag 7 april 2009

Introducing the DialogHandlerHelper

Many questions on the watin-users mailinglist (and about WatiN in general) are about handling dialogs with WatiN. WatiN has build in support for handling many of Internet Explorers dailogs but it is hard to find out which DialogHandler is the right one for the job.

WatiN 2.0 beta 1 introduced the new DialogHandlerHelper class. DialogHandlerHelper can be used to investigate which DialogHandler can be used for a specific dialog. The following example shows you how to use the DialogHandlerHelper .

image

Lets walk through the example. First it creates an IE instance and navigates to a page. Then an instance of DialogHandlerHelper is created and registered with the DialogWatcher. A button is clicked which shows a dialog. The DialogHandlerHelper will now inspect the dialog and close it. Finally the CandidateDialogHandlers are written to the console window for you to inspect and create your final solution.

For this example that would be:

image

 

Just a thought

To make it even more simple, wouldn’t it be great if someone combined the following into a windows forms app:

  • http://www.codeproject.com/KB/dialog/FindWindow.aspx: To let the user point at the dialog that needs to be automated.
  • The code inside DialogHandlerHelper to inspect the chosen dialog and find candidate dailoghandlers.
  • And, when a Dialoghandler is available for the dialog, uses the the class documentation that comes with the dialoghandler to show you example code about using that specific dialoghandler.

Volunteers?

Technorati Tags:

1 reacties:

Cecil zei

I would really like to see a similar example using the FileUploadDialogHandler.