Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom attributes/properties in WinAppDriver. #2047

Open
kfertitta opened this issue Jan 25, 2025 · 5 comments
Open

Custom attributes/properties in WinAppDriver. #2047

kfertitta opened this issue Jan 25, 2025 · 5 comments

Comments

@kfertitta
Copy link

I'm testing a WPF app and have tried exposing some public properties from my custom control AutomationPeer classes. The goal is to enable our UI tests to call GetProperty/GetAttribute to infer some additional context about the element. In my attempts thus far, GetProperty throws an exception and GetAttribute returns null.

Is there a way to do this?

@kfertitta
Copy link
Author

Thanks @anunay1 . That's useful and it works. Tested ItemType by overriding GetItemTypeCore in my automation peer class and binding it to a property in my view model. I was then able to get that value via AppiumWebElement.GetAttribute("ItemType").

I was originally asking if the set of retrievable attributes could be expanded to something arbitrary instead of those values on AutomationProperties. But, I think for my current purposes, I can just hijack the ItemType property and put my own custom data there.

Do you see any issues with hijacking ItemType to hold arbitrary text that is meaningful only in my application (or is that its actual intended usage)?

Thanks again.

@anunay1
Copy link

anunay1 commented Jan 27, 2025

I don't see any issue in highjacking as long as it's shown in inspect.exe. And in visual studio there is an option to enable automation properties some checkbox please check . It's very helpful as you don't need to write code manually.

@kfertitta
Copy link
Author

Sorry, but you lost me with that last bit. I'm not sure what that setting is or what it enables. I also don't understand how I don't have to write any code manually. I don't have to write much for our custom controls -- just a single override. Not sure how Visual Studio itself would know about domain-specific ItemType data we need to surface. We have a bunch of WPF controls embedded within our VSIX in Visual Studio. Our product integrates with Visual Studio itself, so we have a need to automation some of the native VS controls, like Solution Explorer, and that's pretty easy. But, we also have a need to surface automation data for our own controls.

Just wanna make sure I'm not missing something you're trying to emphasize.

@anunay1
Copy link

anunay1 commented Jan 28, 2025

Leave it seems like they have removed that option in latest versions of visual studio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants