This is a migrated thread and some comments may be shown as answers.

Unable to click on OK of a Confirmation Dialog

7 Answers 210 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Abdul Khader
Top achievements
Rank 1
Abdul Khader asked on 18 Nov 2016, 11:17 AM

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

using ArtOfTest.WebAii.Win32.Dialogs;
<br>Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;<br>ConfirmDialog cd = ConfirmDialog.CreateConfirmDialog(ActiveBrowser, DialogButton.OK);<br>Manager.DialogMonitor.AddDialog(cd);<br>Manager.DialogMonitor.Start();<br>cd.Window.Close();

7 Answers, 1 is accepted

Sort by
0
Abdul Khader
Top achievements
Rank 1
answered on 18 Nov 2016, 11:18 AM

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();

0
Nikolay Petrov
Telerik team
answered on 23 Nov 2016, 08:52 AM
Hello Abdul,

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
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Briar
Top achievements
Rank 1
answered on 27 Jun 2018, 03:52 PM

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

 

0
Briar
Top achievements
Rank 1
answered on 27 Jun 2018, 05:22 PM

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

0
Elena
Telerik team
answered on 29 Jun 2018, 09:57 AM
Hi 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
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Briar
Top achievements
Rank 1
answered on 29 Jun 2018, 12:35 PM
Thank you, Elena!
0
Elena
Telerik team
answered on 29 Jun 2018, 02:35 PM
Hi Briar,

You are always welcome. We always do appreciate beneficial discussions with our customers! 

Regards,
Elena Tsvetkova
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Abdul Khader
Top achievements
Rank 1
Answers by
Abdul Khader
Top achievements
Rank 1
Nikolay Petrov
Telerik team
Briar
Top achievements
Rank 1
Elena
Telerik team
Share this question
or