public void TestMenuWithSubMenus() { var window = App.GetMainWindow(Uia3Automation); var menu = window.FindFirst(TreeScope.Children, ConditionFactory.Menu()).AsMenu(); Assert.That(menu, Is.Not.Null); var items = menu.MenuItems; Assert.That(items, Has.Length.EqualTo(2)); Assert.That(items[0].Current.Name, Is.EqualTo("File")); Assert.That(items[1].Current.Name, Is.EqualTo("Edit")); var subitems1 = items[0].SubMenuItems; Assert.That(subitems1, Has.Length.EqualTo(1)); Assert.That(subitems1[0].Current.Name, Is.EqualTo("Exit")); var subitems2 = items[1].SubMenuItems; Assert.That(subitems2, Has.Length.EqualTo(2)); Assert.That(subitems2[0].Current.Name, Is.EqualTo("Copy")); Assert.That(subitems2[1].Current.Name, Is.EqualTo("Paste")); var subsubitems1 = subitems2[0].SubMenuItems; Assert.That(subsubitems1, Has.Length.EqualTo(2)); Assert.That(subsubitems1[0].Current.Name, Is.EqualTo("Plain")); Assert.That(subsubitems1[1].Current.Name, Is.EqualTo("Fancy")); }
public void TestMenuControls() { var application = FlaUI.Core.Application.Launch(@"D:\dotNET\projects\FlaUiPractice\FlaUIPractice\FlaUiTests\Resources\WinFormsApplication.exe"); var automation = new UIA3Automation(); var mainWindow = application.GetMainWindow(automation); ConditionFactory cf = new ConditionFactory(new UIA3PropertyLibrary()); var menu = mainWindow.FindFirstDescendant(cf.Menu()).AsMenu(); menu.DrawHighlight(); menu.Items["File"].Invoke(); mainWindow.FindFirstDescendant(cf.ByName("ContextMenu")).AsButton().RightClick(); var contextMenu = mainWindow.ContextMenu; contextMenu.DrawHighlight(); contextMenu.Items[0].DrawHighlight(); }