Assert.Fail失败了。 System.NotSupportedException:" HasFocus"的GetProperty控件类型不支持:Window

时间:2014-06-24 11:21:10

标签: c# firefox coded-ui-tests notsupportedexception

我正在尝试在FireFox浏览器中运行我的Coded UI测试并收到错误消息:

  

Assert.Fail失败。 System.NotSupportedException:控件类型不支持“HasFocus”的GetProperty:Window

我正在尝试在FireFox浏览器中运行我的Coded UI测试并收到错误消息:

  

Assert.Fail失败。 System.NotSupportedException:控件类型不支持“HasFocus”的GetProperty:Window

    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();

    }

0 个答案:

没有答案