WinAppDriver-使用xpath识别Value.Value属性 [英] WinAppDriver - identifying Value.Value property using xpath

查看:779
本文介绍了WinAppDriver-使用xpath识别Value.Value属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,对于我们的应用程序,通常在很多地方缺少自动化ID,而只有很好的唯一标识符.

So for our application, there are several places where we are missing automation IDs and just good unique identifiers in general.

在一种特殊情况下,我可以使用的唯一好的标识符是Inspect工具识别的Value.Value属性.

In one particular case the only good identifier that I can use is a Value.Value property identified by the Inspect tool.

我尝试使用基本的xpath命令来抓取此元素.

I tried grabbing this element using a basic xpath command..

FindElementByXPath("//*[@Value.Value='" + value + "']");

但这不起作用... WinAppDriver可以任何方式使用这些属性吗?

But this did not work... Can WinAppDriver use these properties in any way?

推荐答案

您可以执行以下操作.如果有一个类名,则可以获取该类的所有控件,然后获取Value.Vaue属性,并在找到它后执行操作.

You can do something like this. If there is a class name, you can get all the controls with the class, and then get attribute Value.Vaue, and perform your operation after finding it.

代码看起来像这样.

var elements = WindowsDriver.FindElementsByClassName("<YourClassName>");
    foreach (var element in elements)
        {
                    if (element.GetAttribute("Value.Value") == "Notes")
                    {
                        //Do your stuff
                        //return the element
                    }
                }

这篇关于WinAppDriver-使用xpath识别Value.Value属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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