Unable to click on OK of a Confirmation Dialog

8 posts, 0 answers
  1. Abdul Khader
    Abdul Khader avatar
    32 posts
    Member since:
    Feb 2016

    Posted 18 Nov 2016 Link to this post

    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();
  2. Abdul Khader
    Abdul Khader avatar
    32 posts
    Member since:
    Feb 2016

    Posted 18 Nov 2016 in reply to Abdul Khader Link to this post

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

  3. Nikolay Petrov
    Admin
    Nikolay Petrov avatar
    308 posts

    Posted 23 Nov 2016 Link to this post

    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!
  4. Briar
    Briar avatar
    68 posts
    Member since:
    Jun 2014

    Posted 27 Jun Link to this post

    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

     

  5. Briar
    Briar avatar
    68 posts
    Member since:
    Jun 2014

    Posted 27 Jun in reply to Briar Link to this post

    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

  6. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    934 posts

    Posted 29 Jun Link to this post

    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!
  7. Briar
    Briar avatar
    68 posts
    Member since:
    Jun 2014

    Posted 29 Jun in reply to Elena Tsvetkova Link to this post

    Thank you, Elena!
  8. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    934 posts

    Posted 29 Jun Link to this post

    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!
Back to Top