예제 #1
0
        public static GuiFileDialog Find(AutomationElement window, string caption)
        {
            AutomationElement dlg = null;
            //* Works fine on Windows 8.1, but not on Windows 7 with only .Net 4.0 installed.
            // * We need to retest this after upgrading to .Net 4.6
            int maxRetries = 120;
            while (dlg == null && maxRetries > 0) {
                try {
                    //dlg = window.FindChildByLocalizedControlTypeAndName(caption, AutomationExtensions.DialogLocalizedControlNameOptions); //different name options on different language settings
                    dlg = window.FindChildByControlTypeAndName(ControlType.Window, caption);
                } catch (Exception) {
                    if (maxRetries <= 0)
                        throw;
                }
                if (dlg == null && maxRetries % 10 == 0) {
                    Log.DebugFormat("File dialog not found: {0}   Caption: {1}", maxRetries, caption);
                }
                Thread.Sleep(500);
                maxRetries--;
            }
            //*/

            //Until this method gets reworked, let developer-machines sleep for 6 seconds instead of 60, for faster testing
            /*
            if (ApplicationLauncher.VerifyOnDeveloperMachine()) {
                Thread.Sleep(6000);
            } else {
                Thread.Sleep(60000);
            }
             */
            return new GuiFileDialog(dlg, window, caption);
        }
예제 #2
0
 public static GuiButton GetButton(AutomationElement window, string name)
 {
     AutomationElement res;
     if (name == "Close")
         res = window.FindChildByControlTypeAndAutomationIdAndName(ControlType.Button, "button", name);
     else
         res = window.FindChildByControlTypeAndName(ControlType.Button, name);
     return new GuiButton(res, name);
 }
예제 #3
0
 public static GuiTabItem GetTabByName(AutomationElement parentWindow, string name)
 {
     if (_cachedTab == null || _cachedTab.AutomationId != name) {
         var res = parentWindow.FindChildByControlTypeAndName(ControlType.TabItem, name);
         _cachedTab = new GuiTabItem(res, name);
         _currentParentWindow = parentWindow;
     }
     return _cachedTab;
 }
예제 #4
0
 public static GuiMenuItem GetMenuItem(AutomationElement window, string name)
 {
     AutomationElement res;
     if (name == "Close")
         res = window.FindChildByControlTypeAndAutomationIdAndName(ControlType.MenuItem, "menuitem", name);
     else
         res = window.FindChildByControlTypeAndName(ControlType.MenuItem, name);
     return new GuiMenuItem(res);
 }
예제 #5
0
 public static GuiExpander GetExpander(AutomationElement window, string name)
 {
     AutomationElement res = window.FindChildByControlTypeAndName(ControlType.Group, name);
     return new GuiExpander(res, name);
 }
예제 #6
0
 public static GuiRadioButton GetRadioButton(AutomationElement window, string name)
 {
     AutomationElement res = window.FindChildByControlTypeAndName(ControlType.RadioButton, name);
     return new GuiRadioButton(res);
 }
예제 #7
0
 public static GuiTextBox GetTextBoxByName(AutomationElement window, string name)
 {
     if (_cachedtb == null || _cachedtb.Name != name) {
         var tb = window.FindChildByControlTypeAndName(ControlType.Edit, name);
         _cachedtb = new GuiTextBox(tb);
     }
     return _cachedtb;
 }