Exemplo n.º 1
0
 /// <summary>
 /// Handles the Click event of the AddAction control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
 private void AddAction_Click(object sender, RoutedEventArgs e)
 {
     var action = new ClickAction();
     _package.Actions.Add(action);
     RefreshTreeView(action);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Reads the JSON representation of the object.
        /// </summary>
        /// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader" /> to read from.</param>
        /// <param name="objectType">Type of the object.</param>
        /// <param name="existingValue">The existing value of object being read.</param>
        /// <param name="serializer">The calling serializer.</param>
        /// <returns>
        /// The object value.
        /// </returns>
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            ActionBase action = null;
            var condition = Condition.Equals;
            var actionName = string.Empty;
            var path = string.Empty;
            var value = string.Empty;
            var text = string.Empty;
            var expectedValue = string.Empty;
            var expectedText = string.Empty;
            var seconds = 0;

            while (reader.Read() && reader.TokenType != JsonToken.EndObject)
            {
                if (reader.TokenType == JsonToken.PropertyName)
                {
                    switch (reader.Value as string)
                    {
                        case "action":
                            actionName = reader.ReadAsString();
                            break;

                        case "path":
                            path = reader.ReadAsString();
                            break;

                        case "value":
                            value = reader.ReadAsString();
                            break;

                        case "text":
                            text = reader.ReadAsString();
                            break;

                        case "expectedValue":
                            expectedValue = reader.ReadAsString();
                            break;

                        case "expectedText":
                            expectedText = reader.ReadAsString();
                            break;

                        case "condition":
                            condition = (Condition)Enum.Parse(typeof (Condition), reader.ReadAsString(), true);
                            break;

                        case "seconds":
                            seconds = reader.ReadAsInt32() ?? 10;
                            break;
                    }
                }
            }

            switch (actionName)
            {
                case "click":
                    action = new ClickAction { Condition = condition, Path = path, Text = text, Value = value };
                    break;

                case "enterKey":
                    action = new EnterKeyAction { Condition = condition, Path = path, Text = text, Value = value };
                    break;

                case "navigateTo":
                    action = new NavigateToAction { Path = path };
                    break;

                case "selectItem":
                    action = new SelectItemAction { Condition = condition, Path = path, Text = text, Value = value };
                    break;

                case "setText":
                    action = new SetTextAction { Path = path, Value = value };
                    break;

                case "test":
                    action = new TestAction { Condition = condition, Path = path, ExpectedText = expectedText, ExpectedValue = expectedValue };
                    break;

                case "wait":
                    action = new WaitAction { Seconds = seconds };
                    break;
            }

            return action;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Changes the type of the action.
        /// </summary>
        private void ChangeActionType()
        {
            var selectedAction = PackageTreeView.SelectedItem as ActionBase;
            if (!_isChangingAction && selectedAction != null && ActionComboBox.SelectedItem != null)
            {
                var helper = new PackageHelper(_package);
                var action = ActionComboBox.SelectedItem as ComboBoxItem;

                if (action != null)
                {
                    switch (action.Tag.ToString())
                    {
                        case "Click":
                            if (selectedAction.GetType() != typeof(ClickAction))
                            {
                                var replacementAction = new ClickAction();
                                helper.ReplaceAction(selectedAction, replacementAction);
                                RefreshTreeView(replacementAction);
                            }
                            break;

                        case "EnterKey":
                            if (selectedAction.GetType() != typeof(EnterKeyAction))
                            {
                                var replacementAction = new EnterKeyAction();
                                helper.ReplaceAction(selectedAction, replacementAction);
                                RefreshTreeView(replacementAction);
                            }
                            break;

                        case "NavigateTo":
                            if (selectedAction.GetType() != typeof(NavigateToAction))
                            {
                                var replacementAction = new NavigateToAction();
                                helper.ReplaceAction(selectedAction, replacementAction);
                                RefreshTreeView(replacementAction);
                            }
                            break;

                        case "SelectItem":
                            if (selectedAction.GetType() != typeof(SelectItemAction))
                            {
                                var replacementAction = new SelectItemAction();
                                helper.ReplaceAction(selectedAction, replacementAction);
                                RefreshTreeView(replacementAction);
                            }
                            break;

                        case "SetText":
                            if (selectedAction.GetType() != typeof(SetTextAction))
                            {
                                var replacementAction = new SetTextAction();
                                helper.ReplaceAction(selectedAction, replacementAction);
                                RefreshTreeView(replacementAction);
                            }
                            break;

                        case "Test":
                            if (selectedAction.GetType() != typeof(TestAction))
                            {
                                var replacementAction = new TestAction();
                                helper.ReplaceAction(selectedAction, replacementAction);
                                RefreshTreeView(replacementAction);
                            }
                            break;

                        case "Wait":
                            if (selectedAction.GetType() != typeof(WaitAction))
                            {
                                var replacementAction = new WaitAction();
                                helper.ReplaceAction(selectedAction, replacementAction);
                                RefreshTreeView(replacementAction);
                            }
                            break;
                    }
                }
            }
        }