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!