我正在尝试在 FireFox 浏览器中运行我的 Coded UI 测试并收到一条错误消息:
断言失败失败。System.NotSupportedException:控件类型不支持“HasFocus”的 GetProperty:窗口
我正在尝试在 FireFox 浏览器中运行我的 Coded UI 测试并收到一条错误消息:
断言失败失败。System.NotSupportedException:控件类型不支持“HasFocus”的 GetProperty:窗口
private void NewHouseCalcTest(Action<test.Web.Testing.Utility> testGroup)
{
DataRow dr = TestContext.DataRow;
Assertions assert = new Assertions(TestContext);
NewHouseUIMapClasses.LoadNewHouseUrlParams win = this.NewHouseUIMap.LoadNewHouseUrlParams;
win.UINewHouseCalculatorHoWindowUrl = Common.GetParamValue(dr, "NewHouseUrl", win.UINewHouseCalculatorHoWindowUrl);
if (Common.IsIterationEnabled(TestContext.DataRow))
{
using (test.Web.Testing.Utility util = new test.Web.Testing.Utility(TestContext, 2000, TestContext.ResultsDirectory))
{
// The following entries set the browser, either Internet Explorer or Firefox and whether or not to clear cookies and/or cache
if (String.IsNullOrEmpty(BrowserWindow.CurrentBrowser))
{
BrowserWindow.CurrentBrowser = "Internet Explorer";
}
BrowserWindow.ClearCache();
BrowserWindow.ClearCookies();
// If we have a test case associated with this test, grab the data from the parameters
// Populate the PageName and BrowserWindow of the util class
util.PageName = this.NewHouseUIMap.LoadNewHouseUrlParams.UINewHouseCalculatorHoWindowUrl;
util.BrowserWindow = this.NewHouseUIMap.UINewHouseCalculatorHoWindow;
try
{
util.RunTestStep("OpenNewHouseCalc", "Open NewHouse Calc Home Page ", () => this.NewHouseUIMap.LoadNewHouseUrl(), 5000);
testGroup(util);
util.CloseCurrentBrowser();
}
catch (Exception e)
{
Assert.Fail(e.ToString());
}
finally
{
util.CloseBrowserWindows();
}
}
}
}
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.TestCase"," http://tfs.test.com:8080/tfs/enterprise;Microsoft .Net", "12004", DataAccessMethod.Sequential), TestMethod]
//验证文本框是否为空的方法,然后错误消息应该在新房子计算器中可见。
public void NewHouseWithoutVal()
{
Action<test.Web.Testing.Utility> testGroup = util =>
{
Assertions assert = new Assertions(TestContext);
// Grabbing values from test case manager into dr.
DataRow dr = TestContext.DataRow;
NewHouseUIMapClasses.ClickCalculateParams TextBoxVal = this.NewHouseUIMap.ClickCalculateParams;
// Grabbing values from dr into variables.
TextBoxVal.UIWagesEditText = Common.GetParamValue(dr, "Wages", "");
TextBoxVal.UIInvestmentsDividendsEditText = Common.GetParamValue(dr, "Investments", "");
#region Variable Declarations
HtmlDiv loanPageHeading = this.NewHouseUIMap.UINewHouseCalculatorHoWindow.UINewHouseCalculatorHoDocument1.LoanPageHeading;
HtmlSpan wagesMessage = this.NewHouseUIMap.UINewHouseCalculatorHoWindow.UINewHouseCalculatorHoDocument1.UINewhousePane.WagesMessage;
HtmlSpan investmentMessage = this.NewHouseUIMap.UINewHouseCalculatorHoWindow.UINewHouseCalculatorHoDocument1.UINewhousePane.InvestmentMessage;
#endregion
// Method to click on "Calculate" button.
util.RunTestStep("ClkCalculate", "Click Calculate Button without value", () => this.NewHouseUIMap.ClickCalculate(), 5000);
// Assertion to verify header page text and empty textboxes error messages.
assert.AreEqual("Mortgage calculator - How much house can you afford?", loanPageHeading.InnerText);
assert.AreEqual("This field is required.", wagesMessage.InnerText);
assert.AreEqual("This field is required.", investmentMessage.InnerText);
};
NewHouseCalcTest(testGroup);
}
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.TestCase", "http://tfs.test.com:8080/tfs/enterprise;Microsoft .Net", "12041", DataAccessMethod.Sequential), TestMethod]
public void NewHouseWithoutValFF()
{
BrowserWindow.CurrentBrowser = "Firefox";
NewHouseWithoutVal();
}