コード例 #1
0
        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);
            }
        }
コード例 #2
0
        /// <summary>
        /// Send File/New command.
        /// </summary>
        internal void New()
        {
            ContextMenu subMenu = MainMenu.OpenSubMenu("MenuFile");

            subMenu.InvokeMenuItem("MenuFileNew");

            Thread.Sleep(300);

            AutomationElement child = this.FindChildWindow("Save Changes", 1);

            if (child != null)
            {
                MessageBoxWrapper msg = new MessageBoxWrapper(child);
                msg.ClickNo();
                Thread.Sleep(300);
            }

            child = this.FindChildWindow("New Database", 1);
            if (child != null)
            {
                MessageBoxWrapper msg = new MessageBoxWrapper(child);
                msg.ClickOk();
                Thread.Sleep(300);
            }
        }
コード例 #3
0
        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);
        }