WatiN - interact with IE modal dialog browser window (c#)

I'm trying to use WatiN to automate downloading of files from a site.  The site lets me select all the files from grid and click a button to download.  Upon clicking download, the browser pops open a modal window that has me enter a name for the zip file prior to clicking save.
I'm having trouble getting WatiN to type the text into the text field.

Here is the code that opens the modal.
	// open zip file name dialog screen, to capture what user wants zip file name to be
   	var result;
	if (window.showModalDialog) { //IE
		result = window.showModalDialog("WBBSZipname.html", "DlgWin", "dialogWidth=1000px;dialogHeight=640px;help=no;status=no");
		if (result == null || result == "") 
			return;

		fm.target = "_self";    
	    fm.ZipFileName.value = result;
	    fm.MultInd.value = DownVal;    
	    fm.CheckedFileNames.value = fnames;    
	    
		fm.submit();
	}

Open in new window


here is the code inside the modal window
<form onsubmit="JavaScript:GetZipFileName('OK');return false;">
<table width="100%" border="0" cellpadding="0"
	cellspacing="0" class="tableForms2">

	<tr>
        <td class="formTitle" height="35">Enter a Zip File Name for the multiple files selected</td>
        <td class="formTitle">&nbsp;</td>
    </tr>
    <tr>        
        <td class="formTitle" height="35">Extension of .ZIP is assumed</td>
        <td class="formTitle">&nbsp;</td>
    </tr>
    <tr>                
        <td class="formTitle" height="35">File names can contain numbers, letters(upper/lower), dash, underline and space.  (The latter 3 cannot be the first character)</td>
        <td class="formTitle"><br /></td>        
    </tr>
    
    </table>
    <table width="100%" border="0" cellpadding="0"
	    cellspacing="0" class="tableForms">
    
    <tr>
    	<td height="35" width="12%" colspan="2" class="formTitle">
    	<input type="text" name="zipFileName" maxlength="35" style="width: 157px"/></td> 
		<td height="35" class="formTitle">&nbsp;</td>
     </tr>
    <tr>
        <td class="formTitle" align="center">
        <input class="buttonBlue" type="button" value="OK" onclick="JavaScript:GetZipFileName('OK');"></input>&nbsp;&nbsp;&nbsp;
        <input class="buttonBlue" type="button" value="CANCEL" onclick="JavaScript:GetZipFileName('CANCEL');"></input>        
    </td>
    </tr>
	
</table>

Open in new window


and here is some of the code i've tried to access the modal, non of which seems to work... note that Browser variable is an IE window via Browser = new IE(logInUrl) from elsewhere in the software.

var dialog = Browser.HtmlDialog(Find.ByUrl(url => url.Contains(@"WBBSZipname")));
                        var modalUrl = dialog.Url;

                        Browser.Eval("alert('" + modalUrl + "');");
                        dialog.Close();

                        var ie2 = new IE(modalUrl);
                        ie2.TextField(Find.ByName("zipFileName")).Value = transferSystemDownloadStruct.TransferSystemDownload.FileName;
                    
                        var okButton = ie2.Button(Find.ByValue("OK"));
                        okButton.Click();

                        download.WaitUntilFileDownloadDialogIsHandled(DownloadDialogHandleTimeout);
                        download.WaitUntilDownloadCompleted(DownloadCompletionTimeout);

                            //Settings.AutoCloseDialogs = true;
                            //var popupWindow = WatiN.Core.Browser.AttachTo<IE>(Find.ByUrl(url => url.Contains(@"WBBSZipname")));
                            //popupWindow.DialogWatcher.CloseUnhandledDialogs = true;
                            //popupWindow.Eval("alert('I'm on the modal!!!');");

                            ////pop up window will ask for file name
                            //var textField = popupWindow.TextField(Find.ByName("zipFileName"));
                            //textField.TypeText(transferSystemDownloadStruct.TransferSystemDownload.FileName);

                            //var okButton = popupWindow.Button(Find.ByValue("OK"));
                            //okButton.Click();

                            //download.WaitUntilFileDownloadDialogIsHandled(DownloadDialogHandleTimeout);
                            //download.WaitUntilDownloadCompleted(DownloadCompletionTimeout);

Open in new window


If it were a real popup rather than a Modal, i know how to handle it, but nothing seems to be working, so I must be doing something wrong.
Robert HamelSenior .NET developerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Robert HamelSenior .NET developerAuthor Commented:
I think i've made progress...
  using (HtmlDialog htmlDialog = Browser.HtmlDialog(Find.ByUrl(url => url.Contains(@"WBBSZipname"))))
                        {

                            var textField = htmlDialog.TextField(Find.ByName("zipFileName"));
                             textField.TypeText(transferSystemDownloadStruct.TransferSystemDownload.FileName);


                             var okButton = htmlDialog.Button(Find.ByValue("OK"));
                             okButton.Click();

                            


                        }

Open in new window


Finally seeing action happening in the window.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.