Unable to click on a tree item in outlook

May 18, 2011 at 1:20 PM


I am trying to click on the Inbox tree node in Outlook 2010 and I get a null reference exception. The stack trace is pasted below. 

at White.Core.UIItems.TreeItems.WPFTreeNode.get_SelectPoint() in c:\white\Core\UIItems\TreeItems\WPFTreeNode.cs:line 19
   at White.Core.UIItems.TreeItems.TreeNode.DoubleClick() in c:\white\Core\UIItems\TreeItems\TreeNode.cs:line 103
   at TestWhite.Program.Main(String[] args) in E:\Workouts\Workouts\TestWhite\Program.cs:line 26

List<Window> ws = Desktop.Instance.Windows();
// Do this as the title of outlook changes when a different folder is selected in outlook
Window outlookWindow = ws.SingleOrDefault((w) => { return w.Name.Contains("Microsoft Outlook"); }); Tree mailBox = outlookWindow.Get<Tree>(SearchCriteria.ByText("Mail Folders")); mailBox.Node("Maddy", "Inbox").Click();

And mailBox.Node("Maddy").Click() also doesn't work.

When I watch the mailBox I do see the child element "Inbox" in it.

Please help me with this.

May 19, 2011 at 7:18 AM


try to debug :)

mailBox element seems to be valid right and not null?

problem is

mailBox.Node("Maddy", "Inbox").Click();

so is the tree node "Inbox" visible in the test?


TreeNode node = mailbox.Nodes(p=>p.Name == "Maddy").First();

TreeNode inbox = node.Nodes(p=>p.Name == "Inbox").First();

this is more stable than the above code. In some cases White can't expand the tree correct.



May 19, 2011 at 10:23 AM

Hi Throndorin,


 I have exactly the same problem, 

I tried your solution.. but 

mailbox.Nodes(p=>p.Name == "Maddy").First();
gives a error : Error 1 Non-invocable member 'White.Core.UIItems.TreeItems.Tree.Nodes' cannot be used like a method.

Here's what I'm trying to do
<!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas} span.s1 {color: #32a2ba} span.s2 {color: #b52422} -->

 White.Core.UIItems.TreeItems.WPFTreeNode drf = OutlookWindow.Get<White.Core.UIItems.TreeItems.WPFTreeNode>("Drafts");


 but this returns same error as Maddy mentioned.
When inspected the properties of drf, I saw 
SelectPoint = 'drf.SelectPoint' threw an exception of type 'Bricks.BricksException'

May 19, 2011 at 1:59 PM

I tried the same Throndorin, however get the same error as swamy has mentioned.

I did the following

            TreeNode node = mailBox.Nodes.Where(p => p.Name == "Maddy").First();;

On debugging saw that WPFTreeNode.GetExpandCollapseButton() is throwing an exception. Going deeper automationElement is null.

- Maddy

May 19, 2011 at 2:08 PM


the problem is, that White looks for a expander Button as subelement for TreeNodes, these button is visible if the node can be expanded.

"normal" WPFTreeNodes have such a button. In Outlook the button is visible for the user but not for UIAutomation.

I can't say why.



May 19, 2011 at 3:41 PM

I have worked out a Work Around...

<!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas} span.s1 {color: #32a2ba} span.s2 {color: #b52422} -->

White.Core.UIItems.TreeItems.WPFTreeNode drf = OutlookWindow.Get<White.Core.UIItems.TreeItems.WPFTreeNode>("Drafts");

<!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas} span.s1 {color: #32a2ba} span.s2 {color: #1738f5} -->

Point pt = new System.Windows.Point();

pt = drf.AutomationElement.GetClickablePoint();

<!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas} span.s1 {color: #32a2ba} -->

White.Core.InputDevices.AttachedMouse mouse = OutlookWindow.Mouse;




May 20, 2011 at 4:48 AM

Thanks Throndorin for the explanation.

Thanks Swamy! That worked.