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); }
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); }
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; }
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); }
public static GuiExpander GetExpander(AutomationElement window, string name) { AutomationElement res = window.FindChildByControlTypeAndName(ControlType.Group, name); return new GuiExpander(res, name); }
public static GuiRadioButton GetRadioButton(AutomationElement window, string name) { AutomationElement res = window.FindChildByControlTypeAndName(ControlType.RadioButton, name); return new GuiRadioButton(res); }
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; }