Hello WinAppDriver Team,
I would like to propose an enhancement in the XPath engine of WinAppDriver.
I see that all windows elements which are available in Inspect.exe have their properties in lowercase
but while building the Page source I see the first letter of Windows elements are uppercase
like Edit, Window etc..
In below screenshot, the window object mentioned in Inspect.exe and the exported page source shows differently.

If we could have uniformity in object naming then building XPath would be very easy and object discovery would be much simpler.
I learned that W3C specification says the tags mentioned in XPath should be in lower case letter.
@dhapolapankaj True but LocalizedControlType is language dependent (over here I get "venster" in Dutch). So it's a valid remark but not so useful for users whose Windows is not set to English.
On another note: does XPath even work with your WindowsDriver code? Here I get absolutely no results from XPath whatsoever... See issue 216.
@Exoow It was just an example.
BTW, I am able to locate any windows element present in Page Source. I am very fond of XPath and I use it heavily in my project. The only problem is it is slower than other locators like ID or Name.
The reason I raised this enhancement proposal will resolve your issue. The case sensitivity in XPath tags and attribute is main culprit you are not able to locate elements.
While embarking on WinAppDriver it took me sufficient amount of time to understand the XPath resolution behavior. Just give the Page source, I can locate any element and can create complex XPaths too ;)
Regards
PD
@dhapolapankaj Okay thanks, makes sense.
If you would be so kind to help, here you can see the first part of my Page Source, and my failing XPath. I have tried many variations but none work.
https://sqa.stackexchange.com/questions/28163/appium-why-does-xpath-not-work-at-all-as-expected
@Exoow could you please try solution mentioned in issue number #216
Hi Pankaj
How can I export page source for a UWP app, for which I don't have the source code i.e I have to automate the UWP app after deployment.
HI @anunayaabb,
PageSource attribute is available from any element and can be retrieved as shown in the following snippet taken from https://github.com/Microsoft/WinAppDriver/blob/v1.0/Tests/WebDriverAPI/Source.cs#L39
c#
var source = session.PageSource;
Hi @anunayaabb
Please refer the code snippet from here
http://simplifyautomation.blogspot.in/2017/11/code-to-save-iwebdriverpagesource-in.html
Xpath is throwing element not found exception but through UI recorder i got the below xpath:
/Pane[@Name=\"Desktop 1\"][@ClassName=\"#32769\"]/Window[@Name=\"Calculator ‎- Calculator\"][@ClassName=\"ApplicationFrameWindow\"]/Window[@Name=\"Calculator\"][@ClassName=\"Windows.UI.Core.CoreWindow\"]/Group[@AutomationId=\"NumberPad\"]/Button[@AutomationId=\"num8Button\"][@Name=\"Eight\"]
Anyone look into this what wrong with this xpath
Hi @prasanna532,
If you're still facing this issue with the latest WinAppDriver v1.1.1 patch, can you please create a new ticket? Thanks!