ui-automation - UIA 验证无法识别 System.Windows.Forms.ListView 复选框

标签 ui-automation uia

我对 UI 自动化和 UI 验证工具还很陌生。

在我们的应用程序中,我们使用 System.Windows.Forms.ListView,并将 CheckBoxes 属性设置为 true。

CheckBoxes 属性允许您在列表中的每个项目旁边显示一个复选框。这使您的应用程序能够显示项目列表(如果 View 属性设置为 View.Details,则显示子项目)

到目前为止,单个行和每行中的所有值均已识别。只有复选框未被 UI 验证识别。


命名空间 WindowsFormsApplication1 { 公共(public)部分类 Form1 :表格 { 公共(public)表格1() { 初始化组件()

        listView1.CheckBoxes = true;
        listView1.View = View.Details;
        listView1.Columns.Add("Automation");
        listView1.Columns.Add("result");
        listView1.Items.Add(new ListViewItem(new string[] { "1", "Pass" }));
    }

}

输出:UIA 验证可识别值“1”和“pass”。但是该复选框未被识别。


还有其他人经历过类似的行为吗?如果是这样,有什么解决办法吗?

非常感谢您的帮助。

问候 哈日原

最佳答案

据我所知,整个列表项都支持切换模式。

enter image description here

所以您应该能够使用行控件本身的切换模式。

    /// <summary>
    /// Toggles anything that supports the toggle pattern
    /// </summary>
    /// <param name="aeElement">Automation element to toggle</param>
    public void Toggle(AutomationElement aeElement)
    {
            TogglePattern tpToggle = (TogglePattern)aeElement.GetCurrentPattern(TogglePattern.Pattern);
            tpToggle.Toggle();
    }

关于ui-automation - UIA 验证无法识别 System.Windows.Forms.ListView 复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25525512/

相关文章:

java - QTP 没有记录 Java 应用程序

python - 如何将 POINT 结构传递给 Python 中的 ElementFromPoint 方法?

javascript - UIA 使用纯 JavaScript 调用,不知道如何访问 DOM-Tree

vb.net - 在 VB.NET 表单中打开 Lotus Notes

tfs - 作为 CI 的一部分运行自动化 UI 测试

ios - 葫芦 iOS : how to get value using query command

accessibility - IAccessible、IAccessible2、UIAutomation 和 MSAA 之间有什么区别?

c# - Mono 没有找到 UIA Bridge,但是包已经安装了

javascript - 数组的处理;由 iOS UI 自动化中的方法返回