Not all tests play out directly inside a browser. Web pages can display popup dialog windows such as alerts, confirmations and others. Testing Framework allows you to track and respond to dialog windows and can handle HTML popups and Win32 dialogs. It is not a difficult task to write code that handles dialogs. However, I will show you how you can create universal dialog handlers so that you do not need to write boilerplate code.

Download File Dialog The first case that we are going to cover is the one for downloading files.

If you are just getting started with Testing Framework I recommend you to read my post- Getting Started with Testing Framework C# in 10 Minutes. Download Dialog Handler Testing Framework You should first create DownloadDialogsHandler with the appropriate parameters. After that, you start a dialog monitor and navigate to the desired page. After you click on the download button, the dialog is automatically handled by Testing Framework engine.

If the file exists on the disk, the test deletes it. Through AppDomain.CurrentDomain.BaseDirectory we access the folder of the tests' assemblies. Universal Download Dialog Handler We can create a static class that hides the complexity of the Testing Framework dialog handler.

In general, the code does the same. We need to pass the clicking of the download button as an anonymous action.

Upload File Dialog The next thing that we want to be able to do is to upload files.

Upload File Dialog Handler Testing Framework The code is almost identical to the previous one except this time we create FileUploadDialog and pass different parameters.

Universal File Upload Dialog Handler Again we create a static class that hides the file dialog handler code's complexity.

The usage in tests is straightforward.

Confirmation Dialog The last scenario that I am going to cover is dedicated to the confirmation dialog.

Confirmation Dialog Handler Testing Framework

Universal Confirmation Dialog Handler We create a static ConfirmationDialogHandler class. You can even specify which dialog button to be clicked.