我正在为我的网站编写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;
}