codeD的用户界面 - 使用UITestControlCollection FindMatchingControls()是连续运行的空 [英] Coded UI - UITestControlCollection using FindMatchingControls() is empty on consecutive runs

查看:262
本文介绍了codeD的用户界面 - 使用UITestControlCollection FindMatchingControls()是连续运行的空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 SpecFlow codeD UI 以创建一些自动化功能测试的 WPF 应用程序。

I use SpecFlow with Coded UI to create some automated functional tests for a WPF application.

让我们来看看下面的SpecFlow情况:

Let's see the following SpecFlow scenario:

Scenario: Issue
When Results button is pressed
    When Result 123 is selected
When Results button is pressed
    When Result 123 is selected

第1和第3行参数:结果

第2和第4行参数: 123

下面是用于上提到的步骤的方法:

Here are the methods for the upper mentioned steps:

当结果按钮是pressed

public void PressButton(string buttonName)
        {
            WpfButton uIButton = this.UIAUT.UIButton;
            uIButton.SearchProperties[WpfButton.PropertyNames.Name] = buttonName;

            uIButton.WaitForControlEnabled();
            Mouse.Click(uIButton);
        }

当选择结果123

public void SelectResultByID(string resultId)
        {
            WpfListItem uIResult = this.UIAUT.UITier1List.UITier2ListBox.UITier3ListItem;
            var allResults = uIResult.FindMatchingControls();

            foreach (WpfListItem item in allResults)
            {
                string[] elem = item.GetChildren().GetNamesOfControls();
                    if (elem[0] == resultID)
                    {
                        Mouse.Click(item);
                    }
            }
        }

前三排都OK。当第4步当结果123被选中再次执行 VAR allResults = uIResult.FindMatchingControls(); 是空的,所以在的foreach 部分被跳过,不采取任何措施,并测试通过。

The first three rows are OK. When the 4th step When Result 123 is selected is executed again var allResults = uIResult.FindMatchingControls(); is empty so the foreach part is skipped, no action is taken and the test is passed.

有人能告诉我什么是错?很明显,我想念的东西。
谢谢!

Could someone tell me what is wrong? It is obvious that I miss something. Thank you!

推荐答案

假设你code通过记录产生(或类似),那么我会怀疑更高级别的UI控件的cacheing的本质。该应用程序可以得出包含第一个 123 一个UI控制和借鉴其他UI控件,第二 123 。这些控件看起来相同,但都不同,有不同的窗口ID(或手柄或其他)。其中的UI控件的

Assuming you code is generated by recording (or is similar) then I would suspect the "cacheing" nature of the higher level UI Controls. The application may draw one UI Control containing the first 123 and draw another UI Control for the second 123. These controls look identical but are different and have different window-ids (or handles or whatever). One of the UI Controls in

WpfListItem uIResult = this.UIAUT.UITier1List.UITier2ListBox.UITier3ListItem;

大概是指第一次的UI控件 123 ,即使它是展出不再。我怀疑 UITier3ListItem 或它的子控件;如果它是 ... 1 ... ... 2 ... 然后我会想到失败消息而不是零匹配。

probably refers to the UI Control of the first 123 even though it is no longer on display. I suspect UITier3ListItem or its child controls; if it were ...1... or ...2... then I would expect a failure message rather than zero matches.

这篇关于codeD的用户界面 - 使用UITestControlCollection FindMatchingControls()是连续运行的空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆