Team,
I am unable to Click on "OK" on a Confirmation Dialog. This step is very important in my script. Please guide me.
I have seen Documentation regarding this and tried in many ways. But still no go. Attached the Snapshot
Here is the code
7 Answers, 1 is accepted
Rewriting the above code
using ArtOfTest.WebAii.Win32.Dialogs;
Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
ConfirmDialog cd = ConfirmDialog.CreateConfirmDialog(ActiveBrowser, DialogButton.OK);
Manager.DialogMonitor.AddDialog(cd);
Manager.DialogMonitor.Start();
cd.Window.Close();
Try to comment the final line and add the following lines:
//cd.Window.Close();
Pages.DialogsTestingPage.ConfirmButtonTag.Click(
false
);
cd.WaitUntilHandled(2000);
Adjust to your case the page element "DialogsTestingPage" in the expression.
Let us know if this works for you.
Regards,
Nikolay Petrov
Telerik by Progress
Hi, this post has proven very helpful. However, I am running into an additional problem.
In my coded step, I've set up a confirmDialog "cd":
Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
ConfirmDialog cd = ConfirmDialog.CreateConfirmDialog(ActiveBrowser, DialogButton.OK);
Manager.DialogMonitor.AddDialog(cd);
Manager.DialogMonitor.Start();
Log.WriteLine("Confirm Dialog Monitoring: "+cd.ToString());
Log.WriteLine("Confirm Dialog Monitoring: State is "+cd.CurrentState.ToString());
Later in the coded step:
for (int j=0; j < removals.Length; j++) {
Log.WriteLine("Confirm Dialog Monitoring: State is "+cd.CurrentState.ToString());
String s = "deleteForm('"+removals[j]+"')";
Log.WriteLine("InvokeScript with: "+s);
Actions.InvokeScript(s);
cd.WaitUntilHandled(2000);
}
After the first script invocation, the confirm dialog is handled by the code but subsequent iterations wait on input from the user. The log has "Unexpected dialog encountered. Taking no action" error messages.
Prior to the first iteration, the state of the confirm dialog is "NotActive". Afterwards, it is "State is Handled."
Any guidance would be much appreciated. Thanks!
Briar
An addendum - Within the loop, I added code to stop, remove, recreate and start the custom dialog handling before each script invocation and I now get the behavior I wanted. My question at this point is - is this the correct way to add custom dialog handling in a iterative situation or am I missing an obvious solution?
Thanks!
Briar
Thank you for sharing details about the chosen approach.
You have found the correct way to handle dialogs in iterative mode - the DialogMonitor needs to be added and started again before each dialog to be handled.
I hope this is helpful to you. Do not hesitate to contact us again in case of any further queries you might have on the topic. Thanks!
Regards,
Elena Tsvetkova
Progress Telerik
You are always welcome. We always do appreciate beneficial discussions with our customers!
Regards,
Elena Tsvetkova
Progress Telerik