Search code examples
c#wpfwinappdriver

WinAppDriver - identifying Value.Value property using xpath


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.

enter image description here

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?


Solution

  • 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
                        }
                    }