private void InitWidgetSet() { var set = _flexLayout.GetFirstWidgetSet(); if (set != null) { foreach (var cnt in set.Containers) { IUIItemContainer uicnt = cnt as IUIItemContainer; if (uicnt != null) { var node = CreateContainerNode(cnt); trvWidgets.Nodes.Add(node); foreach (var wgtref in uicnt.Items) { var child = CreateNode(wgtref); node.Nodes.Add(child); if (wgtref.Function == UiItemFunctionType.Flyout) { ProcessFlyoutChildren(child, (IFlyoutItem)wgtref); } } } } } }
public CalcMenu(IUIItemContainer mainFrame) { var menuBar = mainFrame.Get <MenuBar>(SearchCriteria.ByAutomationId("MenuBar")); Scientific = menuBar.MenuItem("Mode", "Scientific"); Standard = menuBar.MenuItem("Standard"); }
public static T get <T>(this IUIItemContainer container, string text) where T : UIItem { if (container.notNull()) { var match = container.Get <T>(text); if (match.notNull()) { return(match); } return(container.Get <T>(SearchCriteria.ByText(text))); } return(null); }
private static void TryClickNextNsisButton(IUIItemContainer target, Action <string> statusCallback) { statusCallback("Looking for buttons to press..."); var allButtons = target.GetMultiple(SearchCriteria.ByControlType(typeof(Button), WindowsFramework.Win32)) .Cast <Button>(); // Filter out buttons that should not be pressed like "Cancel". var filteredButtons = allButtons.Where(x => x.Enabled).Where(NotControlBoxButton).ToList(); var buttons = filteredButtons.Count > 1 ? filteredButtons .Where(x => !BadButtonIds.Any(y => x.Id.Equals(y, StringComparison.InvariantCulture))) .ToList() : filteredButtons; if (buttons.Any()) { var nextButton = buttons.FirstOrDefault(x => GoodButtonIds.Any( y => x.Id.Equals(y, StringComparison.InvariantCulture))); if (nextButton == null) { nextButton = TryGetByName(buttons); if (nextButton == null) { //Debug.Fail("Nothing to press!"); return; } } // Finally press the button, doesn't require messing with the mouse. //nextButton.RaiseClickEvent(); ProcessRadioButtons(target, statusCallback); statusCallback(string.Format(Localization.Message_Automation_ClickingButton, nextButton.Text)); nextButton.Focus(); nextButton.KeyIn(KeyboardInput.SpecialKeys.RETURN); } }
/// <summary> /// Returns true if a button was clicked. /// </summary> private static void TryClickNextNsisButton(IUIItemContainer target) { var badButtons = new[] { NsisCancelAutomationId, NsisNoAutomationId }; var goodButtons = new[] { NsisForwardAutomationId, NsisYesAutomationId }; var allButtons = target.GetMultiple(SearchCriteria.ByControlType(typeof(Button), WindowsFramework.Win32)) .Cast <Button>(); // Filter out buttons that should not be pressed like "Cancel". var filteredButtons = allButtons.Where(x => x.Enabled).Where(NotControlBoxButton).ToList(); var buttons = filteredButtons.Count > 1 ? filteredButtons .Where(x => !badButtons.Any(y => x.Id.Equals(y, StringComparison.InvariantCulture))) .ToList() : filteredButtons; if (buttons.Any()) { var nextButton = buttons.FirstOrDefault(x => goodButtons.Any( y => x.Id.Equals(y, StringComparison.InvariantCulture))); if (nextButton == null) { nextButton = TryGetByName(buttons); if (nextButton == null) { Debug.Fail("Nothing to press!"); return; } } // Finally press the button, doesn't require messing with the mouse. //nextButton.RaiseClickEvent(); nextButton.Focus(); nextButton.KeyIn(KeyboardInput.SpecialKeys.RETURN); } }
public StandardWorkingArea(IUIItemContainer mainFrame) { var calcFrame = mainFrame.Get <Panel>(SearchCriteria.ByClassName("CalcFrame")); Button0 = new Button(calcFrame, SearchCriteria.ByAutomationId("130"), "0"); Button1 = new Button(calcFrame, SearchCriteria.ByAutomationId("131"), "1"); Button2 = new Button(calcFrame, SearchCriteria.ByAutomationId("132"), "2"); Button3 = new Button(calcFrame, SearchCriteria.ByAutomationId("133"), "3"); Button4 = new Button(calcFrame, SearchCriteria.ByAutomationId("134"), "4"); Button5 = new Button(calcFrame, SearchCriteria.ByAutomationId("135"), "5"); Button6 = new Button(calcFrame, SearchCriteria.ByAutomationId("136"), "6"); Button7 = new Button(calcFrame, SearchCriteria.ByAutomationId("137"), "7"); Button8 = new Button(calcFrame, SearchCriteria.ByAutomationId("138"), "8"); Button9 = new Button(calcFrame, SearchCriteria.ByAutomationId("139"), "9"); ButtonMplus = new Button(calcFrame, SearchCriteria.ByAutomationId("125"), "M+"); ButtonMR = new Button(calcFrame, SearchCriteria.ByAutomationId("123"), "MR"); ButtonPlus = new Button(calcFrame, SearchCriteria.ByAutomationId("93"), "+"); ButtonEqual = new Button(calcFrame, SearchCriteria.ByAutomationId("121"), "="); Result = new Label(calcFrame, SearchCriteria.ByAutomationId("150"), "Result"); }
private static void ProcessRadioButtons(IUIItemContainer target, Action <string> statusCallback) { var allRadios = target.GetMultiple(SearchCriteria.ByControlType(typeof(RadioButton), WindowsFramework.Win32)) .Cast <RadioButton>().ToList(); if (allRadios.Any()) { statusCallback(String.Format(Localization.Message_Automation_FoundButtons, allRadios.Count)); // Select all known good radio buttons first var goodRadios = allRadios.Where(x => GoodRadioIds.Any( y => y.Equals(x.Id, StringComparison.OrdinalIgnoreCase))); foreach (var radioButton in goodRadios) { if (radioButton.Enabled) { statusCallback(String.Format(Localization.Message_Automation_SelectingGoodButton, radioButton.Name)); radioButton.IsSelected = true; } } // Check if any known bad radio buttons are still enabled. If yes, select other, non-bad buttons. var badRadios = allRadios.Where(x => BadRadioIds.Any( y => y.Equals(x.Id, StringComparison.OrdinalIgnoreCase))).ToList(); if (badRadios.Any(x => x.Enabled && x.IsSelected)) { foreach (var notBadRadio in allRadios.Except(badRadios)) { if (notBadRadio.Enabled) { statusCallback(String.Format(Localization.Message_Automation_SelectingNotBadButton, notBadRadio.Name)); notBadRadio.IsSelected = true; } } } } }
public IWindowFixture AutoFill(SearchCriteria by, object seed = null) { var searchItems = _fixture.Instance.GetMultiple(by); List <IUIItem> items = new List <IUIItem>(); foreach (var item in searchItems) { IUIItemContainer container = item as IUIItemContainer; if (container != null) { items.AddRange(container.GetMultiple(SearchCriteria.All)); } else { items.Add(item); } } ProcessUIItems(items, seed); return(_fixture); }
public static T find <T>(this IUIItemContainer container, string text) where T : UIItem { return(container.get <T>(text)); }
internal AttachedKeyboard(IUIItemContainer container, IKeyboardWithActionListener keyboard) { this.container = container; this.keyboard = keyboard; }
internal AttachedKeyboard(IUIItemContainer container, IKeyboard keyboard) : this(container, TryMouseWithActionListener(keyboard)) { }
public Button(IUIItemContainer container, SearchCriteria criteria, string elementName) : base(elementName) { _button = container.Get <UIButton>(criteria); }
public ScientificWorkingArea(IUIItemContainer mainFrame) : base(mainFrame) { }
public Label(IUIItemContainer container, SearchCriteria criteria, string elementName) : base(elementName) { _label = container.Get <UILabel>(criteria); }