microsoft / WinAppDriver

Windows Application Driver
MIT License
3.7k stars 1.4k forks source link

Xpath axes in WinappDriver #1647

Open Yougesh12 opened 2 years ago

Yougesh12 commented 2 years ago

I am facing an issue for how to make xpath axes in Desktop apllication.Can you help me with the sample code

anunay1 commented 2 years ago

check this

Yougesh12 commented 2 years ago

@anunay1 this is for xpath only but i want to make a xpath axes

anunay1 commented 2 years ago

so far as I know its not supported yet. @DHowett Correct it if I am wrong.

Yougesh12 commented 2 years ago

Please help me on this @DHowett if you know that xpath axes is supported in Desktop Application

anunay1 commented 2 years ago

I developed custom methods for child, next item previous item etc

Yougesh12 commented 2 years ago

is it working ?

anunay1 commented 2 years ago

Of course it's working

Yougesh12 commented 2 years ago

I developed custom methods for child, next item previous item etc

are you saying this about web application or Desktop application

Yougesh12 commented 2 years ago

Or i am understanding something worng..Where you use the xpath axes??

anunay1 commented 2 years ago

I developed custom methods for the functionality provided by xpath axes.

anunay1 commented 2 years ago

I developed custom methods for child, next item previous item etc

are you saying this about web application or Desktop application

Desktop application

Yougesh12 commented 2 years ago

can you share the code?

anunay1 commented 2 years ago

To get the children the code is:

public static IEnumerable GetChildrens(this WindowsElement windowsElement) { return windowsElement.FindElementsByXPath("/").ToList(); }

To get the first element:

var editorLineNumberElement = session.FindElementByAccessibilityId("specialAutomationIdYouGave"); var textBoxElements = editorLineNumberElement.FindElementsByClassName("TextBox");

var firstElement = textBoxElements.FirstOrDefault();

To get the last element: var editorLineNumberElement = session.FindElementByAccessibilityId("specialAutomationIdYouGave"); var textBoxElements = editorLineNumberElement.FindElementsByClassName("TextBox"); var lastElement = textBoxElements.LastOrDefault();

anunay1 commented 2 years ago

Also check #1441