コード例 #1
0
        private void AddActions()
        {
            BrowserWindow watinie = Action.Window;
            ModelSet      wscript = Action.AppContext.ActionModel;

            foreach (GridRow o in gridElement.Rows)
            {
                var element = o.Tag as IHTMLElement;
                if (element == null)
                {
                    continue;
                }
                var val = element.getAttribute("value", 0);
                if (element.tagName == "SELECT")
                {
                    //wscript.AddClick(watinie, element);
                    wscript.AddAction(Action.AppContext, ActionEnum.ActionClick.ToString(), new ActionClickParameter()
                    {
                        Element = element,
                    });
                    wscript.AddAction(Action.AppContext, ActionEnum.ActionSelectList.ToString(),
                                      new Core.ActionBuilder.SelectParameter()
                    {
                        ByValue = (val != null), Element = element
                    });
                }
                else if (element.tagName == "INPUT")
                {
                    var type = element.getAttribute("type", 0).ToString().ToLower();
                    if (type == "checkbox" || type == "radio")
                    {
                        // wscript.AddClick(watinie, element, true);
                        wscript.AddAction(Action.AppContext, ActionEnum.ActionClick.ToString(), new ActionClickParameter()
                        {
                            Element = element,
                        });
                    }
                    else
                    {
                        //wscript.SbKeys = new StringBuilder(val == null ? "" : val.ToString());
                        //wscript.AddTyping(watinie, element, false, true);
                        wscript.AddAction(Action.AppContext, ActionEnum.ActionTypeText.ToString(),
                                          new ActionTypingParameter()
                        {
                            Element     = element,
                            XPathFinder = false,
                            SbKeys      = (val == null ? "" : val.ToString())
                        });
                    }
                }
            }
        }
コード例 #2
0
        private void Write(List <IHTMLElement> activeElements)
        {
            if (activeElements.Count == 0)
            {
                return;
            }
            IAppContext context = AppContext.Current;
            ModelSet    model   = new ModelSet(new CustomScriptWriteRepository(Identity.UserId, scriptId));

            foreach (var o in activeElements)
            {
                var type = ActionElementBase.TagStringToElementType(o);
                switch (type)
                {
                case ElementTypes.TextField:
                    model.AddAction(context, ActionEnum.ActionTypeText.ToString(),
                                    new ActionTypingParameter()
                    {
                        Element     = o,
                        XPathFinder = false
                    });
                    break;

                case ElementTypes.RadioButton:
                    model.AddAction(context, ActionEnum.ActionRadio.ToString(), new ActionClickParameter()
                    {
                        Element = o,
                    });
                    break;

                case ElementTypes.CheckBox:
                    model.AddAction(context, ActionEnum.ActionCheckbox.ToString(), new ActionClickParameter()
                    {
                        Element = o,
                    });
                    break;

                case ElementTypes.SelectList:
                    model.AddAction(context, ActionEnum.ActionSelectList.ToString(),
                                    new Core.ActionBuilder.SelectParameter()
                    {
                        ByValue = true, Element = o
                    });
                    break;

                default:
                    break;
                }
            }
            activeElements.Clear();
            model.Save();
        }