Beispiel #1
0
 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());
     }
 }
Beispiel #2
0
        public static void By(AutomationElement element, int index, bool isDouble)
        {
            var logger = InjectionHelper.GetInstance <DesktopLogger>();

            if (isDouble && element.ControlType == ControlType.Tree)
            {
                var tree = element.AsTree();
                var item = tree.FindChildAt(index);
                DoubleClick.On(item);

                logger.Write(tree, "has been selected");
            }
        }
Beispiel #3
0
        //TODO
        public static void By(AutomationElement element, int index, VirtualKeyShort virtualKeyShort = VirtualKeyShort.TAB)
        {
            var logger = InjectionHelper.GetInstance <DesktopLogger>();

            if (element.ControlType == ControlType.ComboBox)
            {
                var combo = element.AsComboBox();
                combo.Expand();
                combo.Select(index);
                combo.Collapse();
                Keyboard.Press(virtualKeyShort);

                logger.Write(combo, "has been selected");
            }
            if (element.ControlType == ControlType.Tree)
            {
                var tree = element.AsTree();
                var item = tree.FindChildAt(index);
                Click.On(item);

                logger.Write(tree, "has been selected");
            }
        }
Beispiel #4
0
        private static void OnElement(AutomationElement element)
        {
            element.Focus();

            switch (element.ControlType)
            {
            case ControlType.AppBar:
                break;

            case ControlType.Button:
                element.AsButton().DoubleClick();
                break;

            case ControlType.Calendar:
                break;

            case ControlType.CheckBox:
                break;

            case ControlType.ComboBox:
                break;

            case ControlType.Custom:
                break;

            case ControlType.DataGrid:
                break;

            case ControlType.DataItem:
                break;

            case ControlType.Document:
                break;

            case ControlType.Edit:
                break;

            case ControlType.Group:
                break;

            case ControlType.Header:
                break;

            case ControlType.HeaderItem:
                break;

            case ControlType.Hyperlink:
                break;

            case ControlType.Image:
                break;

            case ControlType.List:
                break;

            case ControlType.ListItem:
                element.AsListBoxItem().DoubleClick();
                break;

            case ControlType.MenuBar:
                element.AsMenu().DoubleClick();
                break;

            case ControlType.Menu:
                element.AsMenu().DoubleClick();
                break;

            case ControlType.MenuItem:
                element.AsMenuItem().DoubleClick();
                break;

            case ControlType.Pane:
                break;

            case ControlType.ProgressBar:
                break;

            case ControlType.RadioButton:
                element.AsRadioButton().DoubleClick();
                break;

            case ControlType.ScrollBar:
                break;

            case ControlType.SemanticZoom:
                break;

            case ControlType.Separator:
                break;

            case ControlType.Slider:
                break;

            case ControlType.Spinner:
                break;

            case ControlType.SplitButton:
                break;

            case ControlType.StatusBar:
                break;

            case ControlType.Tab:
                break;

            case ControlType.TabItem:
                element.AsTabItem().DoubleClick();
                break;

            case ControlType.Table:
                break;

            case ControlType.Text:
                break;

            case ControlType.Thumb:
                break;

            case ControlType.TitleBar:
                element.AsTitleBar().DoubleClick();
                break;

            case ControlType.ToolBar:
                break;

            case ControlType.ToolTip:
                break;

            case ControlType.Tree:
                element.AsTree().DoubleClick();
                break;

            case ControlType.TreeItem:
                element.AsTreeItem().DoubleClick();
                break;

            case ControlType.Window:
                break;

            default:
                element.DoubleClick();
                break;
            }
        }