Hi,
I am trying to open one Alert dialog and do some operation on it using webAii automation.The scenario is like this:
1.I want to delete a record.So I am selecting one record
2.Clicking on Remove selecetd record button.Onclick of this I am getting one Alert dialog.
3.After clicking on this button the Alert pop up is coming and it is getting closed before the test script goes to next line
4.I am not able to capture the dialog in Dialog monitor
Please help me on this.
6 Answers, 1 is accepted
What may be happening is our "Unexpected Dialog Handler" feature is getting in the way. Try turning it off using this line of code at the beginning of your test:
Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
Cody
Thanks a lot for your reply.....
Now what is happening is the Alert dialog which is opened is not getting closed immediately but still it is not going to the next line of code.It will be there in that same line of test and the status will be Processing only in the Browser.
Please help me to resolve this.
Thanks,
Hemashree
I need to see a screenshot of this alert dialog along with your test code. Once you post that I will study it to try and determine why it's not working as expected.
Kind regards,
Cody
the Telerik team
Thanks for the reply.
The code looks like this:
Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
Log.WriteLine(Find.ById<HtmlInputCheckBox>("ScheduleList_ctl00_ctl04_ScheduleSelectSelectCheckBox").Value);
//Click on RemoveSelected button
Find.ById<HtmlInputSubmit>("delete2").Click();
//Handle Alert Dialog
Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
AlertDialog altDlg = new AlertDialog(ActiveBrowser, DialogButton.OK);
Manager.DialogMonitor.AddDialog(altDlg);
Manager.DialogMonitor.Start();
//altDlg.WaitUntilHandled(1000);
Manager.DialogMonitor.RemoveDialog(altDlg);
Please help me to resolve the below issue as I am I need the solution immediately....
-Thanks,
Hemashree
Thank you for that additional information. I think I see what the problem is. You need to setup your dialog handler before you click on the button that causes the alert to open. The dialog handler only watches for new dialogs after the object has been created. It will ignore dialogs that already are present at the time you create your dialog handler.
Please try this code instead:
Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
Log.WriteLine(Find.ById<HtmlInputCheckBox>(
"ScheduleList_ctl00_ctl04_ScheduleSelectSelectCheckBox"
).Value);
//Setup Alert Dialog Handler
AlertDialog altDlg =
new
AlertDialog(ActiveBrowser, DialogButton.OK);
Manager.DialogMonitor.AddDialog(altDlg);
Manager.DialogMonitor.Start();
//Click on RemoveSelected button
Find.ById<HtmlInputSubmit>(
"delete2"
).Click();
// Wait until the dialog has been handled
altDlg.WaitUntilHandled(1000);
Manager.DialogMonitor.RemoveDialog(altDlg);
Cody