44using System . Threading ;
55using System . Windows . Automation ;
66using TestStack . White . AutomationElementSearch ;
7+ using TestStack . White . Configuration ;
78using TestStack . White . Factory ;
89using TestStack . White . UIItems . Actions ;
910using TestStack . White . UIItems . Finders ;
11+ using TestStack . White . Utility ;
1012
1113namespace 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