LogonDialogHandler In WATiN

For the automation of some webapplication we have to provide usrname and password in logon poup windows to access that website. For example if you try to access Nagios Monitoring tool it will ask for username and password as popup windows shown in below figure.

To handle this secnario in automation we can use LogonDialogHandler provided in watin framework.

Below is the code snippet to hanlde scenario:

Try
{
Browser browser = new IE();
WatiN.Core.DialogHandlers.LogonDialogHandler ldh = new WatiN.Core.DialogHandlers.LogonDialogHandler(“UserName”,”Password”);
browser.DialogWatcher.Add(ldh);
browser.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Maximize);

browser.GoTo(“NagiosUrl”);
}
catch (Exception ex)
{

//Handle Exception

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s