public void AlertHandlerAdd()
        {
            var actionClick = (ActionClick)AddClick();
            ActionAlertHandler actionAlertHandler = _mgr.AddAlertHandler("normalWindow");

            Assert.AreEqual(2, _mgr.ActionCount, "Actions Not Added");
            Assert.AreEqual(actionClick, actionAlertHandler.WrapAction, "Alert handler not connected");
        }
示例#2
0
        /// <summary>
        /// *INSERTS* an alert handler in the action list, just before the last action
        /// </summary>
        /// <param name="windowName">window where it was performed</param>
        /// <returns>action created (mainly for testing)</returns>
        public ActionAlertHandler AddAlertHandler(string windowName)
        {
            var action = new ActionAlertHandler(_browsers[windowName])
            {
                WrapAction = _actionList[_actionList.Count - 1]
            };

            AddAction(action, _actionList.Count - 1);
            return(action);
        }
        public void AlertHandlerRemovedWhenConnectedIsRemoved()
        {
            var actionClick = (ActionClick)AddClick();
            ActionAlertHandler actionAlertHandler = _mgr.AddAlertHandler("normalWindow");

            Assert.AreEqual(2, _mgr.ActionCount, "Actions Not Added");
            Assert.AreEqual(actionClick, actionAlertHandler.WrapAction, "Alert handler not connected");

            _mgr.RemoveAction(actionClick);
            Assert.AreEqual(0, _mgr.ActionCount, "actions not removed");
        }
示例#4
0
        private string WriteAlertHandlerToFile()
        {
            const string filename    = @"C:\Work\TestRecorder3\tests\output_alerthandler.xml";
            var          clickAction = new ActionClick(new BrowserWindow("window"), GetInputElement("input"));
            var          alertAction = new ActionAlertHandler(new BrowserWindow("window"))
            {
                WrapAction = clickAction
            };

            SerializeActionHelper.SerializeActionListToFile(new List <ActionBase> {
                clickAction, alertAction
            }, filename);
            return(filename);
        }
示例#5
0
        public void WriteAlertHandler()
        {
            var generator = new WatiNCSharp(GetNUnitTemplate());
            var clicker   = new ActionClick(new BrowserWindow("window"))
            {
                ActionFinder = new FindAttributeCollection()
            };

            clicker.ActionFinder.AttributeList.Add(new FindAttribute("id", "div1"));
            clicker.ActionFinder.TagName = "Div";

            var alerter = new ActionAlertHandler(new BrowserWindow("window"))
            {
                WrapAction = clicker
            };

            generator.ActionToCode(alerter);
            generator.ActionToCode(clicker);

            Assert.AreEqual(3, generator.Code.Count, "different than 2 code lines");
            Assert.AreEqual(generator.Code[0], "UseDialogOnce(new AlertHandler()){", "alert line other than valid code");
            Assert.AreEqual(generator.Code[1], "divDiv1.Click();", "action line other than valid code");
        }
示例#6
0
        static public ActionBase Create(string ActionObjectString)
        {
            ActionBase output = null;

            try
            {
                output = Activator.CreateInstance("AutoRobo.Core", "AutoRobo.Core.Actions." + ActionObjectString).Unwrap() as ActionBase;
            }
            catch
            {
                //兼容老版本数据
                switch (ActionObjectString)
                {
                case "BrowserClick": output = new ActionClick(); break;

                case "Navigate": output = new ActionNavigate(); break;

                case "ScriptPart": output = new ActionScriptPart(); break;

                case "AlertHandler": output = new ActionAlertHandler(); break;

                case "ActionDoubleClick": output = new ActionDoubleClick(); break;

                case "ActionFireEvent": output = new ActionFireEvent(); break;

                case "ActionKey": output = new ActionKey(); break;

                case "Mouse": output = new ActionMouse(); break;

                case "RadioButton": output = new ActionRadio(); break;

                case "Checkbox": output = new ActionCheckbox(); break;

                case "SelectList": output = new ActionSelectList(); break;

                case "TypeText": output = new ActionTypeText(); break;

                case "DirectionKey": output = new ActionDirectionKey(); break;

                case "Sleep": output = new ActionSleep(); break;

                case "Wait": output = new ActionWait(); break;

                case "ValidateCode": output = new ActionValidateCode(); break;

                case "FileUpload": output = new ActionFileDialog(); break;

                case "ValidateImage": output = new ActionValidateImage(); break;

                case "JavascriptInterpreter": output = new ActionJavascriptInterpreter(); break;

                case "SubmitClick": output = new ActionSubmitClick(); break;

                case "CloseWindow": output = new ActionCloseWindow(); break;

                case "WindowBack": output = new ActionBack(); break;

                case "WindowForward": output = new ActionForward(); break;

                case "WindowOpen": output = new ActionOpenWindow(); break;

                case "WindowRefresh": output = new ActionRefresh(); break;

                case "SubElementFinder": output = new ActionSubElements(); break;

                case "CallFunction": output = new ActionCall(); break;

                case "ActionForeach": output = new ActionForeach(); break;

                case "ActionBrowser": output = new ActionBrowser(); break;

                case "ActionThread": output = new ActionThread(); break;
                    //case "AddChildrenToList": output = new AddChildrenToList(); break;
                }
            }
            //if (output == null)
            //{
            //    throw new ApplicationException(string.Format("{0}对应的活动未找到", ActionObjectString));
            //}

            return(output);
        }