How to open Modal Pop Up Dialog using NUNIT and WATIN
-
Wednesday, February 08, 2012 10:10 AM
Hi,
When i clicked the Button one modal pop up dialog box will open, how to click that open button using watin test.
I used below code , but it doesn't working for me.
public void CheckName()
{
IE ie = new IE("http://localhost:4066/SampleWebSite/Default.aspx");
ie.TextField(Find.ById("txtNickName")).TypeText("Suresh");
ie.Button(Find.ById("btnCheck")).Click();
AlertAndConfirmDialogHandler myHandler = new AlertAndConfirmDialogHandler();
//Declare an object of HTMLDialog
HtmlDialog myModalHandler;
ie.AddDialogHandler(myHandler);
//The button that opens the HTML dialog must be clicked with NO WAIT
ie.Link(Find.ByText("File Download")).ClickNoWait();
//Hook the PopUp by title/name/type etc.
myModalHandler = ie.HtmlDialog(Find.ByTitle(new Regex("Do you want to open or save this file?")));
//Click on button which is on PopUp window.
myModalHandler.Button(new Regex("BtnSubmit")).ClickNoWait();
}Thanks
Suresh
All Replies
-
Thursday, February 09, 2012 2:41 PMModerator
Hi, I'm afraid that WatiN as an open source library is not support on this forum officially. Other people who familiar with it can still help here. Anyway, I'm thinking of sendkey to the dialog and dismiss it. Sendkeys.SendWait("%O") http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx
Could this resolve your question?
Best Regards,
Forrest Guo | MSDN Community Support | Feedback to us
- Edited by Forrest GuoModerator Thursday, February 09, 2012 2:45 PM
-
Tuesday, February 14, 2012 1:35 AMModerator
Hi, do you still need assistance on this question?
Forrest Guo | MSDN Community Support | Feedback to us
-
Wednesday, February 15, 2012 12:14 PM
Thanks for your reply,
I didn't resolve these? if you have idea please help me.
-
Wednesday, February 15, 2012 1:49 PMModerator
Sure. Did you try the SendKeys() suggestion? How is it going?
Best Regards,
Forrest Guo | MSDN Community Support | Feedback to us
-
Thursday, February 16, 2012 12:17 PMYES, i tried but it did not working for me...
-
Thursday, February 23, 2012 1:33 AMAny one has a idea how to do it....
-
Thursday, February 23, 2012 1:59 AMModerator
Hi,
Not sure how the WATIN framework achieve, but I can provide how VSTS Coded UI test do this. The generated code for this very scenario looks like below, hope you can get some idea.
public void RecordedMethod3() { #region Variable Declarations HtmlHyperlink uIScenarioImplementatiHyperlink = this.UISearchResultsrestartWindow.UISearchResultsrestartDocument.UIScenarioImplementatiHyperlink; WinButton uIOpenButton = this.UIWindowsInternetExploWindow.UIWindowsInternetExploPane.UIOpenButton; #endregion // Click 'Scenario Implementation' link Mouse.Click(uIScenarioImplementatiHyperlink, new Point(156, 12)); // Click '&Open' button Mouse.Click(uIOpenButton, new Point(270, 27)); }Best Regards,
Forrest Guo | MSDN Community Support | Feedback to us
-
Thursday, February 23, 2012 2:45 PM
It might be worth asking in the WatiN mailing lists. When I was using WatiN a few years ago I found it helpful.Kevin
- Marked As Answer by Forrest GuoModerator Friday, February 24, 2012 1:19 AM

