I have a requirement that may need to use something like UI Automation so i'm trying to learn the basics but I'm not having much luck.
I found this line of code in a couple of examples from different articles:
var calcWindow = AutomationElement.RootElement.FindFirst(TreeScope.Children,
new PropertyCondition(AutomationElement.NameProperty, "Calculator"));
but whenever I run this line, calcWindow is null. I've noticed that it will be set to a value when I run 2 instances of the calculator.
The same problem applies to RootElement.FindAll where it returns null when a single instance of the calculator runs but when I run 2 instances, it will return a value and its .Count() property is set to 1.
Any ideas?
Thanks.
UPDATE 1
I probably should have included the articles I was looking at:
- manipulating the simple windows Calculator using win32 API in c#?
- Automate your UI using Microsoft Automation Framework
Note that I'm running these tests using .NET 2015 on a Windows 10 Pro 64-bit (os build: 17134.112 - version: 1803).