Skip to content

Commit a5adefd

Browse files
author
Jake Ginnivan
committed
>_<
1 parent 676070d commit a5adefd

File tree

1 file changed

+4
-1
lines changed
  • src/TestStack.White/UIItems/MenuItems

1 file changed

+4
-1
lines changed

src/TestStack.White/UIItems/MenuItems/Menus.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
using System.Threading;
55
using System.Windows.Automation;
66
using TestStack.White.AutomationElementSearch;
7+
using TestStack.White.Configuration;
78
using TestStack.White.Factory;
89
using TestStack.White.UIItems.Actions;
910
using TestStack.White.UIItems.Finders;
11+
using TestStack.White.Utility;
1012

1113
namespace TestStack.White.UIItems.MenuItems
1214
{
@@ -19,7 +21,7 @@ public Menus(AutomationElement parent, ActionListener actionListener)
1921
if (parent == null) throw new ArgumentNullException("parent", "You must specify a parent automation id when creating a menu");
2022
AutomationSearchCondition condition = AutomationSearchCondition.ByControlType(ControlType.MenuItem);
2123
var finder = new AutomationElementFinder(parent);
22-
finder = PerformanceHackAsPopupMenuForWin32AppComesOnDesktop(finder, parent);
24+
finder = Retry.For(()=> PerformanceHackAsPopupMenuForWin32AppComesOnDesktop(finder, parent), CoreAppXmlConfiguration.Instance.BusyTimeout());
2325
List<AutomationElement> children = finder.Descendants(condition);
2426
foreach (AutomationElement child in children)
2527
Add((Menu) Factory.Create(child, actionListener));
@@ -36,6 +38,7 @@ private static AutomationElementFinder PerformanceHackAsPopupMenuForWin32AppCome
3638
AutomationElement windowElement = finder.Child(AutomationSearchCondition.ByControlType(ControlType.Window));
3739
menuElement = new AutomationElementFinder(windowElement).Child(AutomationSearchCondition.ByControlType(ControlType.Menu));
3840
}
41+
if (menuElement == null) throw new UIItemSearchException("Could not find Menu");
3942
finder = new AutomationElementFinder(menuElement);
4043
}
4144
return finder;

0 commit comments

Comments
 (0)