问题
So for our application, there are several places where we are missing automation IDs and just good unique identifiers in general.
In one particular case the only good identifier that I can use is a Value.Value property identified by the Inspect tool.
I tried grabbing this element using a basic xpath command..
FindElementByXPath("//*[@Value.Value='" + value + "']");
But this did not work... Can WinAppDriver use these properties in any way?
回答1:
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.
The code will look something like this.
var elements = WindowsDriver.FindElementsByClassName("<YourClassName>");
foreach (var element in elements)
{
if (element.GetAttribute("Value.Value") == "Notes")
{
//Do your stuff
//return the element
}
}
来源:https://stackoverflow.com/questions/55928563/winappdriver-identifying-value-value-property-using-xpath