简体   繁体   中英

UI Automation's AutomationId inconsistency on different versions of windows

I'm working on automating an application using UI Automation framework (.net 4.6.1).

When inspecting the application using Visual UI Automation Verify i'm able to see the value of AutomationId properties.

I have written a small automation script in C# (wpf)

When I execute my automation script on windows 7, all works fine.

When I try it on windows 10, all the AutomationId values are string empty.

Sample code:

AutomationElement.RootElement.FindFirst (
  TreeScope.Descendants, 
  new PropertyCondition(AutomationElement.AutomationIdProperty, myAutomationId)
);

This sample returns null, because it cannot find an element with myAutomationId value, when I explored all the children of AutomationElement.RootElement I found that the AutomationId values are empty (unlike what i see on Visual UI Automation Verify , and unlike what i get when running on windows 7)

Is there something i'm missing about AutomationId properties? or about how UI Automation framework runs on windows 10?

Edit:

I have noticed that when I loop through the child elements, I have found that some of them have an AutomationId that has a value of the NativeWindowHandle.. why is that??

Edit 2:

I have tried a very wide range of UI Automation dlls with multiple versions, none of was able to even find the application on windows 10.

Same thing goes for TestStack.White (doesn't work on windows 7 either).

The UIA which works fine is UIAutomationClient.dll (+ UIAutomationTypes.dll if needed)

It uses Automation interfaces directly :

IUIAutomation uiautomation = new CUIAutomation();

and so on...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM