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

Confirmation dialog in code behind method

3 Answers 229 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chris Johnson
Top achievements
Rank 1
Chris Johnson asked on 12 May 2010, 10:50 PM

I need to write a step with conditional logic. According to the user guide, this requires a code-behind method. I'm having a problem handling a confirmation dialog within the code-behind method: the dialog does not get dismissed, and the test fails with a timeout.

I have a pure WebAii test that handles the same confirmation successfully, so I generated a unit test from that and copied the dialog manager code you see below. Is this the wrong technique for use in a code-behind?

        [CodedStep(@"Delete customer record if it exists")]  
        public void DeleteCustomerIfExists()  
        {  
            string emailAddress = "abc@xyz.com";  
 
            Pages.CustomerSearch.SearchFor.Text = emailAddress;  
            Pages.CustomerSearch.SearchButton.Click(false);  
 
            HtmlAnchor customerLink = Find.ByAttributes<HtmlAnchor>("title=" + emailAddress);  
            if (customerLink != null)  
            {  
                // Handle 'Confirm' dialog.  
                ConfirmDialog confirmDialog = new ConfirmDialog(ActiveBrowser, DialogButton.OK);  
                Manager.DialogMonitor.AddDialog(confirmDialog);  
 
                // this displays confirmation dialog  
                Pages.CustomerSearch.DeleteCustomerButton.Click(false);  
 
                confirmDialog.WaitUntilHandled(5000);  
            }  
        } 

Thanks!

3 Answers, 1 is accepted

Sort by
0
Accepted
Missing User
answered on 12 May 2010, 11:28 PM
Hello Chris,

Thanks for posting the code. It looks like since you are conditionally adding a dialog handler, presumably no other dialog handler is being explicitly being added to the test.

If this is the case, you would need to start the DialogMonitor manually as in:

Manager.DialogMonitor.Start();

Please reply back if the code above does not resolve the problem

Sincerely,
Nelson Sin
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Chris Johnson
Top achievements
Rank 1
answered on 12 May 2010, 11:40 PM
Thank you for posting the answer so quickly. That worked, and now that you point it out, I see it in the sample code at http://www.artoftest.com/support/webaii/topicsindex.aspx. I apologize for not reading the sample more carefully. Thanks again.
0
Missing User
answered on 13 May 2010, 12:24 AM
Hi again Chris,

I'm glad  to hear that resolved the issue, please feel free to submit  new tickets if you have further questions.

Regards,
Nelson
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
Chris Johnson
Top achievements
Rank 1
Answers by
Missing User
Chris Johnson
Top achievements
Rank 1
Share this question
or