UI Automation

Add-in Express™ Support Service
That's what is more important than anything else

UI Automation
 
Subscribe
Sébastien Lange




Posts: 25
Joined: 2022-09-21
Hi,

I'd like to test my Outlook COM add-in using UI Automation.

I can get the new mail window with code above:

            var mail = (MailItem)_outlookApp.CreateItem(OlItemType.olMailItem);
            mail.Display();

            var process = Process.GetProcessesByName("outlook")[0];
            Condition processIdCondition = new PropertyCondition(AutomationElement.ProcessIdProperty, process.Id);
            var window = AutomationElement.RootElement.FindFirstWithTimeout(TreeScope.Children, processIdCondition, 3000);


But I can't get the main control (whose AutomationId is stackPanel) of my ADXOlForm which is displayed in mail window:

            AutomationElement stackPanel =
                window.FindFirstWithTimeout(TreeScope.Children, new PropertyCondition(
                    AutomationElement.AutomationIdProperty, "stackPanel"), 2000);


stackPanel is null...

Do you have any example about how to use UI Automation to get AutomationElement for an ADXOlForm?

Best regards,
Sébastien
Posted 02 Nov, 2022 09:40:17 Top
Andrei Smolin


Add-in Express team


Posts: 18515
Joined: 2006-05-11
Hello Sébastien,

Are you sure that the the AutomationID property of your ADXOlForm is "stackPanel"? Use Accessibility Insights from https://accessibilityinsights.io/ to verify this.

Regards from Poland (GMT+1),

Andrei Smolin
Add-in Express Team Leader
Posted 03 Nov, 2022 05:03:13 Top
Sébastien Lange




Posts: 25
Joined: 2022-09-21
Thanks for your help.

AutomationID was correct, but I had to use TreeScope.Descendants instead of TreeScope.Children.

Anyway, do you have any samples (projects) that demonstrate some usage of UI Automation? that would help a lot to start...

Best regards,
Sébastien
Posted 03 Nov, 2022 10:08:04 Top
Andrei Smolin


Add-in Express team


Posts: 18515
Joined: 2006-05-11
Hello Sébastien,

No, we don't have such an example.

Regards from Poland (GMT+1),

Andrei Smolin
Add-in Express Team Leader
Posted 04 Nov, 2022 04:11:17 Top
Craig Callender




Posts: 21
Joined: 2021-07-06
Anyway, do you have any samples (projects) that demonstrate some usage of UI Automation? that would help a lot to start...


Hi Sebastien. I wrote up our implementation with some code samples here and here.

Hope that helps!
Posted 09 Dec, 2022 04:42:44 Top
Andrei Smolin


Add-in Express team


Posts: 18515
Joined: 2006-05-11
Thank you very much, Craig!

Regards from Poland (GMT+1),

Andrei Smolin
Add-in Express Team Leader
Posted 12 Dec, 2022 04:34:34 Top