Skip to content

Commit 83e9eec

Browse files
author
Jake Ginnivan
committed
Additional error check
1 parent bf9144a commit 83e9eec

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ namespace TestStack.White.UIItems.MenuItems
1212
{
1313
public class Menus : UIItemList<Menu>
1414
{
15-
private static readonly DictionaryMappedItemFactory Factory = new DictionaryMappedItemFactory();
15+
static readonly DictionaryMappedItemFactory Factory = new DictionaryMappedItemFactory();
1616

1717
public Menus(AutomationElement parent, ActionListener actionListener)
1818
{
19+
if (parent == null) throw new ArgumentNullException("parent", "You must specify a parent automation id when creating a menu");
1920
AutomationSearchCondition condition = AutomationSearchCondition.ByControlType(ControlType.MenuItem);
2021
var finder = new AutomationElementFinder(parent);
2122
finder = PerformanceHackAsPopupMenuForWin32AppComesOnDesktop(finder, parent);

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,26 @@ namespace TestStack.White.UIItems.MenuItems
66
{
77
public class PopUpMenu : UIItem
88
{
9-
private readonly Menus topLevelMenus;
109
protected PopUpMenu() {}
1110

1211
public PopUpMenu(AutomationElement automationElement, ActionListener actionListener) : base(automationElement, actionListener)
1312
{
1413
this.actionListener = actionListener;
15-
topLevelMenus = new Menus(automationElement, actionListener);
1614
}
1715

1816
public virtual Menus Items
1917
{
20-
get { return topLevelMenus; }
18+
get { return new Menus(automationElement, actionListener); }
2119
}
2220

2321
public virtual Menu Item(params string[] text)
2422
{
25-
return topLevelMenus.Find(text);
23+
return Items.Find(text);
2624
}
2725

2826
public virtual Menu ItemBy(params SearchCriteria[] path)
2927
{
30-
return topLevelMenus.Find(path);
28+
return Items.Find(path);
3129
}
3230
}
3331
}

0 commit comments

Comments
 (0)