jeudi 22 septembre 2016

Coded UI Test - Set UI property not returning (hanging indefinitely)

I am getting crazy with a problem that I found when executing a Visual Studio Coded UI Test. The scenario is as follows. I recorded a Coded UI Tests that do the following steps in a Web Application (Microsoft Dynamics CRM 2011):

  • Login into an application
  • Navigate into a page
  • On the page set the selected value of a html combobox

The test is able to do all those steps without a problem, even selecting the value in the combobox. The web application have a piece of Javascript that is executed when the selected item changes. if one of the values is selected then an alert message is presented to the user and the application will set the selected item to a default one!

The javascript code look like this:

    switch (Xrm.Page.getAttribute("status").getValue()) {
    case 3: //Authorised
        alert("Please use the method XPTO to update the record status to Authorised!");
        Xrm.Page.getAttribute("status").setValue(1);
        Xrm.Page.getControl("tatus").setFocus(true);
        return false;

The UI Test method that is performing the change in the combobox is as follows:

    /// <summary>
    /// Select a value in the Status dropdown box
    /// </summary>
    public void SelectStatus()
    {
        #region Variable Declarations
        HtmlComboBox uIStatusComboBox = this.UIHttpsappWindow200.UIModuleUITEDocument5.UIWorkplaceDashboardsFrame.UIModuleUITEDocument.UIStatusComboBox;

        // Select 'Authorised' in 'Status' combo box
        uIStatusComboBox.SelectedItem = this.SelectStatus_SPParams.UIStatusComboBoxSelectedItem;

    }

For some reason the test method is actually able change the value in the combobox, and an alert message is displayed to the user. However this part of the code uIStatusComboBox.SelectedItem = this.SelectStatus_SPParams.UIStatusComboBoxSelectedItem; never returns and the test just hangs there until it timeouts!

I have no ideia how to work arround this issue! I was thinking that maybe the problem could be in the fact that we have javascript code that is executed after the alert is displayed to the user. I changed the JS so that the alert message is the last thing to be displayed but it also didn´t help!

I also noticed that if I click Ok on the alert message the test Pass!

If I select other value that dont trigger any JS the test also Pass!

Does anyone have any idea about this issue?

Aucun commentaire:

Enregistrer un commentaire