当页面在某些事件上获得自动后备时,无法在CodedUI自动化测试中获得控制权

时间:2016-06-17 07:39:50

标签: visual-studio-2012 coded-ui-tests

我正在为我的网站编写CodedUI自动化测试,其中我必须首先从组合框中选择值,在此基础上文本框变得可见,此时发生autopostback所以在记录事件后无法找到文本框它选择组合框值后,在UI中找不到文本框的错误。

public bool testforSearch()
        {
            #region Variable Declarations
            HtmlComboBox uIDdlDistrictsComboBox = this.UIHttpwwwsbssnaponglobWindow.UISearchYourNameEnglisDocument.UIDdlDistrictsComboBox;
            HtmlEdit uITxtEPICNoEdit = this.UIHttpwwwsbssnaponglobWindow.UISearchYourNameEnglisDocument.UITxtEPICNoEdit;
            HtmlInputButton uISearchButton = this.UIHttpwwwsbssnaponglobWindow.UISearchYourNameEnglisDocument.UISearchButton;
            #endregion

            // Go to web page 
            this.UIHttpwwwsbssnaponglobWindow.LaunchUrl(new System.Uri(this.testforSearchParams.UIHttpwwwsbssnaponglobWindowUrl));

            // Select 'Meerut' in 'ddlDistricts' combo box
            uIDdlDistrictsComboBox.SelectedItem = this.testforSearchParams.UIDdlDistrictsComboBoxSelectedItem;

            if (uITxtEPICNoEdit.WaitForControlExist())
            {
                // Type 'abcd' in 'txtEPICNo' text box
                uITxtEPICNoEdit.Text = this.testforSearchParams.UITxtEPICNoEditText;
            }
            else
            {
                return false;
            }

            // Click 'Search' button
            Mouse.Click(uISearchButton, new Point(19, 8));

            return true;
        }

0 个答案:

没有答案