public static void Value(AutomationElement automationElement, string value) { try { if (automationElement.ControlType == ControlType.Edit) { automationElement.AsTextBox().Text.Should().Be(value); } if (automationElement.ControlType == ControlType.ComboBox) { automationElement.AsComboBox().SelectedItem.Text.Trim().Should().Be(value); } if (automationElement.ControlType == ControlType.List) { automationElement.AsListBox().SelectedItem.Text.Trim().Should().Be(value); } if (automationElement.ControlType == ControlType.Tree) { automationElement.AsTree().SelectedTreeItem.Text.Trim().Should().Be(value); } } catch (Exception) { var sb = new StringBuilder(); sb.Append(automationElement.Name); sb.Append(' '); sb.Append(automationElement.ControlType.ToString()); sb.Append("'s value should be '"); sb.Append(value); sb.Append("'"); throw new AssertionException(sb.ToString()); } }
//TODO public static void By(AutomationElement element, string text, VirtualKeyShort?virtualKeyShort = VirtualKeyShort.TAB) { var logger = InjectionHelper.GetInstance <DesktopLogger>(); if (element.ControlType == ControlType.ComboBox) { Wait.UntilResponsive(element); var combo = element.AsComboBox(); combo.Focus(); combo.Expand(); combo.Select(text); combo.Collapse(); Keyboard.Press(virtualKeyShort.Value); logger.Write(combo, "has been selected"); } if (element.ControlType == ControlType.List) { var list = element.AsListBox(); if (virtualKeyShort == null) { var item = list.FindFirstChild(c => c.ByName(text)); Click.On(item); } else { list.Select(text); Keyboard.Press(virtualKeyShort.Value); } logger.Write(list, "has been selected"); } }
void SetStructurePanorama(UIA3Automation automation) { var window2 = app.GetMainWindow(automation); AutomationElement button2 = null; do { button2 = window2.FindFirstDescendant(cf => cf.ByText("Structured panorama")); } while (button2 == null); if (button2 != null && button2.ControlType != ControlType.Button) { button2 = button2.AsButton().Parent; } var list = button2.AsListBox().Select(1); //button2.Click(); }
public ListBox StarItemsListView() { AutomationElement starItemList = this.MainWindow.FindFirstChild("StarItemsList"); return(starItemList.AsListBox()); }