internal bool DeleteAccount(int index) { AutomationElement item = Select(index); string name = item.Current.Name; if (name != "Walkabout.Data.AccountSectionHeader") { ContextMenu menu = new ContextMenu(item, true); menu.InvokeMenuItem("DeleteAccount"); MainWindowWrapper mainWindow = MainWindowWrapper.FindMainWindow(Element.Current.ProcessId); AutomationElement child = mainWindow.FindChildWindow("Delete Account: " + name, 5); if (child != null) { MessageBoxWrapper msg = new MessageBoxWrapper(child); msg.ClickYes(); } else { throw new Exception("Why is there no message box?"); } return(true); } else { return(false); } }
public void AddAccount(string baseName, string type) { string name = GetUniqueCaption(baseName); ContextMenu menu = new ContextMenu(this.Element, true); menu.InvokeMenuItem("NewAccount"); MainWindowWrapper mainWindow = MainWindowWrapper.FindMainWindow(Element.Current.ProcessId); AutomationElement child = mainWindow.FindChildWindow("Account", 5); if (child != null) { AccountSettingsWrapper settings = new AccountSettingsWrapper(child); settings.Name = name; settings.AccountType = type; settings.ClickOk(); return; } throw new Exception("AccountSettings dialog is not appearing!"); }
private void ClickOkIfExists() { // if database exists, click "yes"... MainWindowWrapper main = MainWindowWrapper.FindMainWindow(window.Current.ProcessId); bool found = true; do { found = false; foreach (string title in new string[] { "Database Exists", "Need to Elevate" }) { AutomationElement child = main.FindChildWindow(title, 2); if (child != null) { MessageBoxWrapper msg = new MessageBoxWrapper(child); if (msg != null) { msg.ClickOk(); } found = true; } } }while (found); }
public ContextMenu(AutomationElement control, bool isPopupMenu) { this.isPopupMenu = isPopupMenu; root = MainWindowWrapper.FindMainWindow(control.Current.ProcessId); this.control = control; }
public ContextMenu(AutomationElement control) { root = MainWindowWrapper.FindMainWindow(control.Current.ProcessId).Element; this.control = control; }