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

Unable to use Automation Peer on controls using Mahapps framework #4454

Open
alexandrefaure opened this issue Dec 22, 2023 · 7 comments
Open
Labels

Comments

@alexandrefaure
Copy link

Hi everyone,

We currently have a bug on our application which seems to be directly related to the .Net 8.0 upgrade.
We need to access to AutomationPeers of controls inside our app for our quality team. From the dev side, we use Accessibility Insight to verify that each control in the app have a correct/dedicated AutomationId.

Since we've upgraded to .Net 8.0 last week, we cannot find our controls anymore using Mahapps. When we remove Mahapps lib from our code, everything went fine and we can find our controls.

I can give you a test project with a simple button to test that if necessary.
Of course, we use the latest version of Mahapps.

Feel free to tell me if you need more information.

Thanks again for your help,
Cheers,
Alex

@punker76
Copy link
Member

@alexandrefaure Sorry to here this, a sample would be helpful. Do you use still 2.4.10?

@alexandrefaure
Copy link
Author

Yep for sure we use the version 2.4.10.

Here is a .zip with the light solution with a button in center of a window.
How I made the test :

  1. Run the app without debugging
  2. Launch Accessibility Insight
  3. We can target the control (using AutomationPeers) correctly as shown here :
    image

When it's not working, we cannot targeting the control anymore :
image

Here are the different test cases :

  1. With Mahapps lib + .Net 7.0 set as project target version = OK
  2. With Mahapps lib + .Net 8.0 set as project target version = KO
  3. Without Mahapps lib + .Net 8.0 set as project target version = OK

Here is the .zip file with the solution used for this test.

Hope that helps !
App 8.zip

@noubar
Copy link
Contributor

noubar commented Feb 19, 2024

I can only reassure that the bug is there, because i was having the same problem not only with windows accessibility insights but with inspect.exe from microsoft and UIRecorder from WinAppDriver and FlaUInspect.

Bug reproduction steps are:

  1. Download the zip file
  2. make sure you are using latest metroapp version and .net8
  3. Change the Window under MainWindow.xml to mah:MetroWindow
  4. Build the app
  5. Start the app without debugging
  6. Try to inspect the button with any inspection tool

Expected result:

  • the inspect tool is able to detect the app's button through your mouse position

Actual result:

  • the inspect tool is not able to find the element trough mouse position but jumping to the last list item in the window

Extra info:

These all inspect tools are using the frompoint function from windows https://learn.microsoft.com/en-us/dotnet/api/system.windows.automation.automationelement.frompoint?view=windowsdesktop-8.0

@textdocument
Copy link

I can also confirm that the bug is there.

@noubar
Copy link
Contributor

noubar commented Jul 24, 2024

I have a workaround for this issue, which is not a fix but a total workaround. An updated version of flauinspect.
Which uses focused element instead of mouse position to detect the element. I have an implementation of it here in an inspector app. Use uia2 and activate focus mode.
with holding the right alt click on the searched element.
This way it works.

@lightwalker01
Copy link

@noubar thanks for your comment: unfortunately we cannot apply your workaround so this issue with .Net 8.0, still open after 7 months, is really a problem for us...

Maybe it is related to dotnet/wpf#8679?

@noubar
Copy link
Contributor

noubar commented Jul 24, 2024

It looks like that it is related.
But not 100% the same thing because the error described in there that the element tree is missing some elements i have not observed such an error in the metro window.

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

No branches or pull requests

5 participants