首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不能在TreeItems中使用FlaUI在C#中使用展开和折叠方法或模式吗?

不能在TreeItems中使用FlaUI在C#中使用展开和折叠方法或模式吗?
EN

Stack Overflow用户
提问于 2021-11-24 12:28:25
回答 1查看 47关注 0票数 0

我正在尝试定义一个函数,它通过使用FlaUI在C#中测试程序的目标状态来展开或折叠给定的TreeItem。

我能够找到元素,但无法访问任何用于展开和折叠TreeItem元素的信息或方法。在尝试设置currentPattern变量时,我得到了以下错误。我也不能只在TreeItem上运行展开和折叠方法。

错误:FlaUI.Core.Exceptions.PatternNotSupportedException: 'The requested pattern 'ExpandCollapse [#10005]' is not supported'

我写的函数是:

代码语言:javascript
复制
public TreeItem ToggleTreeNode(string inNodeName, ExpandCollapseState inTargetState, AutomationElement inParentNode = null)
{
    TreeItem nodeElement = null; //TreeItem nodeElement = null;
    if (inParentNode == null)
    {
        nodeElement = mSTGOCMainForm.FindFirstDescendant(cf => cf.ByName(inNodeName)).AsTreeItem();
    }
    else
    {
        nodeElement = inParentNode.FindFirstDescendant(cf => cf.ByName(inNodeName)).AsTreeItem();
    }
    
    // Collapse or Expand
    var currentPattern = nodeElement.Patterns.ExpandCollapse.Pattern;
    var currentState = currentPattern.ExpandCollapseState.Value;

    if (inTargetState != currentState)
    {
        //Then do the operation
        if (inTargetState == ExpandCollapseState.Collapsed)
        {
            nodeElement.Collapse();
        }
        else if (inTargetState == ExpandCollapseState.Expanded)
        {
            nodeElement.Expand();
        }
    }

    return nodeElement;
}

我使用的是3.2.0版本的FlaUI.Core和FlaUI.UIA2。

EN

回答 1

Stack Overflow用户

发布于 2021-11-30 09:58:53

看起来你的TreeItems就是不支持UIA折叠/展开模式。存在支持该模式的嵌套或父元素(使用任何检查工具进行检查),或者需要使用键盘或鼠标来折叠/展开。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70096089

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档