Unable to find elements by using xpath

Hi Appium-Enthusiasts!

I am using Appium and the Appium Windows Driver to automate GUI-Tests of WPF-applications. Finding and working with elements found by the Id-selector for instance works fine.

What I am right now trying to achieve is to find elements by using xpath and the xpath-selector. This works fine for “simple” windows application, such as the Windows Calculator but it seems to fail when applying it to my target application, which has a more complex GUI.

Within the simple text editor baretail.exe (for instance) I am using

"/Window/MenuBar/MenueItem[3]" as xpath-string within the Appium-SessionManager to search for an element. This works fine. Also, called from within source code by stating

var result = session.FindElementsByXPath("/Window/MenuBar/MenueItem[3]")

returns the correct element.

However, when I am applying the same procedure to get elements from my target application, appium seems to be unable to find any element. It keeps feedbacking me that no elements were found.

Not even, when I am using simple xpath-strings such as

"/Window" or “//*”.

One more thing I noted is that when I am comparing the suggested xpath-string the Appium SessionManager shows me and the path in the element-tree shown by microsofts inspect.exe tool to the same element, I see the following syntactic difference w.r.t. the names (casing and spacing):

  • Suggested by Appium-Session-Manager: "/Window/MenuBar/MenueItem[3]"
  • Shown as tree path within inspect.exe: “window” -> “menu bar” -> "menu item"

Can anybody provide me any tipps or suggestions why xpath works in one application but totally fails in another?

Since I am working on a time-critical project I am more than grateful for any help! Regards.

Hi Marc.
I would suggest that if you are facing issues using XPATH and you have control over your windows applications why don’t you give it an Id and get the element using Id that way you don’t need Xpath and xpath is not the quickest of ways to find elements.

Just my 2 cents thought.

Feel free to contact me if you want to discuss

Hi Ahmed,

Thank you very much for your reply. I agree with you but unfortunately my requirement is that I will not be able to assign Id and Names so it seems that I’d need to use xpath to find UI elements.

I am still struggeling around with this issue and somehow I suspect it to be a trivial solution because it works for a simple app like the Windows Calc or a simple notepad - but I am really having a hard time to find out why.

The Appium desktop application keeps tells me the xpath to the UI elements (as described in my original post) but then, the same programm - the appium desktop application - is unable to find UI elemenst by using the xpath it suggested on its own (there’s a search-feature in this Appium desktop application, where you can use an xpath to find UI elements and it works using e.g. calc.exe but fails with my target application).

Slowly, I am running out of ideas …

Don’t you have any idea? Could it be that the names of the application source document are spelled differently as how appium or inspect.exe display them? Do I have access to the applications source XML-file/its UI-tree?

Kindly, Marc

Can you share with me the line of code you are using to find the element ?

yes of course, I would share anything with you :slight_smile:

Since I am not able to use images here, I also opened a thread on stackoverflow, here:


Could I ask you to please refer to this post?

Thanks and regards,

Yes sure no problem i can reply on stackoverflow as well.

Thank you! :slight_smile: