编码的UI:通过自定义代码执行时,具有记录操作的测试用例失败

时间:2013-04-17 08:44:50

标签: coded-ui-tests

    public void RecordedMethod_Sample(int x)
    {
        #region Variable Declarations
        HtmlCell uISALESREVENUECell = this.UIDashboardWindowsInteWindow1.UIDashboardDocument.UITblWrapperOnlineStorTable.UISALESREVENUECell;
        HtmlImage uIImagegifbase64R0lGODImage = this.UIDashboardWindowsInteWindow1.UIDashboardDocument.UIImagegifbase64R0lGODImage;
        HtmlHyperlink uIPostPurchase4Hyperlink = this.UISalesRevenueandGrossWindow.UISalesRevenueandGrossDocument.UIPostPurchase4ReturnsCustom.UIPostPurchase4Hyperlink;
        HtmlDiv uISalesRevenueByDataSoPane = this.UISalesRevenueandGrossWindow.UISalesRevenueandGrossDocument.UISalesRevenueByDataSoPane;
        #endregion

        // Set flag to allow play back to continue if non-essential actions fail. (For example, if a mouse hover action fails.)
        Playback.PlaybackSettings.ContinueOnError = true;

        // Mouse hover 'SALES REVENUE' cell at (82, 27)
        Mouse.Hover(uISALESREVENUECell, new Point(82, 27));

        // Reset flag to ensure that play back stops if there is an error.
        Playback.PlaybackSettings.ContinueOnError = true;

        // Click 'image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAA...' image
        Mouse.Click(uIImagegifbase64R0lGODImage, new Point(139, 64));

        // Set flag to allow play back to continue if non-essential actions fail. (For example, if a mouse hover action fails.)
        Playback.PlaybackSettings.ContinueOnError = true;

        // Mouse hover 'Post Purchase4' link at (144, 19)
        Mouse.Hover(uIPostPurchase4Hyperlink, new Point(144, 19));

        // Reset flag to ensure that play back stops if there is an error.
        Playback.PlaybackSettings.ContinueOnError = true;

        // Move 'Sales Revenue By Data Source' pane
        Mouse.StartDragging(uISalesRevenueByDataSoPane, new Point(79, 15));
        Mouse.StopDragging(uISalesRevenueByDataSoPane, 224, -4);
        string title = uISalesRevenueByDataSoPane.InnerText.ToString();
        if (title == "Sales Revenue By Data Source")
        {

        }

执行Mouse.Hover(uISALESREVENUECell,new Point(82,27));它正在给予 跟随错误 不支持指定的方法。 每当我尝试将其作为测试用例执行时,一切都按预期工作 通过自定义代码执行时,它给出了上述错误 任何人都可以帮帮我... 提前感谢您的所有投入

2 个答案:

答案 0 :(得分:0)

“自定义代码”是什么意思?如果它意味着自定义控件,那么错误很可能是因为尚未编写自定义控件来支持Coded UI。对于使用Coded UI的自定义控件,它必须支持MSAA或UIA接口,或者得到新代理机制的支持。

有关详细信息,请尝试通过网络搜索Coded UI,MSAA和UIA。另请查看此博客http://blogs.msdn.com/b/visualstudioalm/archive/2012/05/24/coded-ui-test-new-extensibility-qfe.aspx

答案 1 :(得分:0)

我遇到了这个问题。

您最好的选择是尽可能多地使用刻录机,然后在需要动态执行时仅将这些内容从UI映射移开,并且只针对这些位。

让录音机为您完成所有工作,在播放过程中您将获得更好的可靠性。