예제 #1
0
        /// <summary>
        /// Adds a click action to the action list
        /// </summary>
        /// <param name="windowName">window where it was performed</param>
        /// <param name="activeElement">element the click was performed on</param>
        /// <param name="url">current url for action</param>
        /// <returns>action created (mainly for testing)</returns>
        public ActionBase AddClick(string windowName, IHTMLElement activeElement, string url)
        {
            ActionBase action = null;

            if (activeElement == null)
            {
                return(null);
            }
            if (activeElement is IHTMLBodyElement)
            {
                return(null);
            }

            if (activeElement is IHTMLSelectElement ||
                activeElement is IHTMLTextAreaElement ||
                (activeElement is IHTMLInputElement && (activeElement as IHTMLInputElement).type == "text"))
            {
                action = new ActionFocus(_browsers[windowName], activeElement, url);
            }
            else
            {
                action = new ActionClick(_browsers[windowName], activeElement, url);
            }

            AddAction(action);
            return(action);
        }
예제 #2
0
        private string WriteClickActionToFile()
        {
            const string filename = @"C:\Work\TestRecorder3\tests\output_click.xml";
            var          action   = new ActionClick(new BrowserWindow("window"), GetInputElement("input"));

            SerializeActionHelper.SerializeActionListToFile(new List <ActionBase> {
                action
            }, filename);
            return(filename);
        }
예제 #3
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);
        }
예제 #4
0
        public void CheckSinglePropertyAttributes()
        {
            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";
            clicker.ActionFinder.ActionUrl = "http://www.fakeurl.com";
            string attribute = generator.GetPropertyAttributeString(clicker.ActionFinder);

            Assert.AreEqual("Find.ById(\"div1\")", attribute);
        }
예제 #5
0
        public void DontDuplicateSameProperty()
        {
            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";
            clicker.ActionFinder.ActionUrl = "http://www.fakeurl.com";
            generator.ActionToCode(clicker);
            generator.ActionToCode(clicker);

            Assert.AreEqual(1, generator.Properties.Count, "More than 1 property created");
        }
예제 #6
0
        public bool insert(string TableName, ActionClick ac, string Name = "", string bz = "")
        {
            LogInfo info = new LogInfo();

            info.Name       = Name;
            info.TableName  = TableName;
            info.OpType     = (int)ac;
            info.Remark     = bz;
            info.Url        = Edu.Tools.WebHelper.GetUrl();
            info.CreateDate = DateTime.Now;
            info.UserID     = LoginUserService.UserID;
            info.UserName   = LoginUserService.userName;
            info.IP         = Edu.Tools.WebHelper.GetIP();
            unitOfWork.DLogInfo.Insert(info);
            unitOfWork.Save();
            return(false);
        }
예제 #7
0
        public void WriteDivClick()
        {
            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";
            generator.ActionToCode(clicker);

            Assert.AreEqual(1, generator.Properties.Count, "different than 1 property");
            Assert.IsNotNull(generator.Properties[0], "property is blank");

            Assert.AreEqual(1, generator.Code.Count, "different than 1 code line");
            Assert.That(generator.Code[0] == "divDiv1.Click();", "other than valid code");
        }
예제 #8
0
        public void WriteLinkClick()
        {
            var generator = new WatiNCSharp(GetNUnitTemplate());
            var clicker   = new ActionClick(new BrowserWindow("window"))
            {
                ActionFinder = new FindAttributeCollection()
            };

            clicker.ActionFinder.AttributeList.Add(new FindAttribute("id", "testlinkid"));
            clicker.ActionFinder.TagName = "a";
            generator.ActionToCode(clicker);

            Assert.AreEqual(1, generator.Properties.Count, "different than 1 property");
            Assert.IsNotNull(generator.Properties[0], "property is blank");
            Assert.That(generator.Properties[0].PropertyCode.Contains("_browser.Link(Find"), "Link code not working");

            Assert.AreEqual(1, generator.Code.Count, "different than 1 code line");
            Assert.That(generator.Code[0] == "aTestlinkid.Click();", "other than valid code");
        }
예제 #9
0
        public void WriteRadioClick()
        {
            var generator = new WatiNCSharp(GetNUnitTemplate());

            var wb   = new WebBrowser();
            var strm = new MemoryStream();

            wb.DocumentStream = strm;

            if (wb.Document == null)
            {
                return;
            }
            HtmlDocument doc  = wb.Document.OpenNew(true);
            string       html = File.ReadAllText(@"C:\Work\TestRecorder3\tests\html\main.html");

            if (doc != null)
            {
                doc.Write(html);
            }

            HtmlElementCollection collection = wb.Document != null?wb.Document.GetElementsByTagName("input") : null;

            if (collection != null)
            {
                var radio = collection.Cast <HtmlElement>().FirstOrDefault(element => element.GetAttribute("type") == "radio");

                if (radio != null)
                {
                    var radioElement = new ActionClick(new BrowserWindow("window"), (IHTMLElement)radio.DomElement);
                    generator.ActionToCode(radioElement);
                }
            }

            Assert.AreEqual(1, generator.Properties.Count, "different than 1 property");
            Assert.IsNotNull(generator.Properties[0], "property is blank");
            Assert.That(generator.Properties[0].PropertyCode.Contains("_browser.RadioButton(Find"), "Radio code not working");

            Assert.AreEqual(1, generator.Code.Count, "different than 1 code line");
            Assert.AreEqual("radioRadio1.Click();", generator.Code[0], "other than valid code");
        }
예제 #10
0
        /// <summary>
        /// 插入日志
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="opID"></param>
        /// <param name="TableName"></param>
        /// <param name="ac"></param>
        /// <param name="bz"></param>
        /// <returns></returns>
        public bool insert(ActionClick ac, object obj, string Name = "")
        {
            string TableName = "";
            string bz        = "";

            Type type = obj.GetType();

            try
            {
                TableName = type.FullName;
                bz        = Edu.Tools.JsonHelper.Instance.Serialize(obj);
            }
            catch (Exception ex) {
                Edu.Tools.LogHelper.Info(ex.Message);
            };
            LogInfo info = new LogInfo();

            if (string.IsNullOrEmpty(Name))
            {
                info.Name = type.Name;
            }
            else
            {
                info.Name = Name;
            }


            info.TableName  = TableName;
            info.OpType     = (int)ac;
            info.Remark     = bz;
            info.Url        = Edu.Tools.WebHelper.GetUrl();
            info.CreateDate = DateTime.Now;
            info.UserID     = LoginUserService.UserID;
            info.UserName   = LoginUserService.userName;
            info.IP         = Edu.Tools.WebHelper.GetIP();
            unitOfWork.DLogInfo.Insert(info);
            unitOfWork.Save();
            return(false);
        }
예제 #11
0
    /// <summary>
    /// Method that happens when the user clicks the mouse in this slot.
    /// </summary>
    /// <param name="eventData">Information about the click</param>
    public void OnPointerClick(PointerEventData eventData)
    {
        if (eventData != null &&
            eventData.button == PointerEventData.InputButton.Left)
        {
            if (Info != null)
            {
                // Contains information about which item is in this slot
                SlotClick?.Invoke(Info);
            }
        }

        if (eventData != null &&
            eventData.button == PointerEventData.InputButton.Right)
        {
            if (Info != null)
            {
                // Contains information about which item is in this slot
                ActionClick?.Invoke(Info);
            }
        }
    }
예제 #12
0
    public void SetupSpellHud(ActionClick anActionClickFunction)
    {
        FindActionBar();

        for (int index = 0; index < myActionButtons.Length; index++)
        {
            int tempIndex = index;

            string name = "ActionButton" + (tempIndex + 1).ToString();
            for (int childIndex = 0; childIndex < myActionBar.transform.childCount; childIndex++)
            {
                if (myActionBar.transform.GetChild(childIndex).name == name)
                {
                    myActionButtons[index] = myActionBar.transform.GetChild(childIndex).gameObject;
                    myActionButtons[index].GetComponent <Image>().sprite = mySpells[index].GetComponent <Spell>().mySpellIcon;
                    myActionButtons[index].GetComponent <ActionKey>().SetDescription(mySpells[index].GetComponent <Spell>().GetSpellDescription());
                    break;
                }
            }

            myActionButtons[tempIndex].GetComponent <Button>().onClick.AddListener(delegate { anActionClickFunction(tempIndex); });
        }
    }
예제 #13
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");
        }
예제 #14
0
        public void CheckUniqueProperty()
        {
            var generator = new WatiNCSharp(GetNUnitTemplate());
            var clicker1  = new ActionClick(new BrowserWindow("window"))
            {
                ActionFinder = new FindAttributeCollection()
            };

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

            var clicker2 = new ActionClick(new BrowserWindow("window"))
            {
                ActionFinder = new FindAttributeCollection()
            };

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

            Assert.AreEqual(2, generator.Code.Count, "different than 2 code lines");
            Assert.AreEqual(generator.Code[1], "divDiv11.Click();", "action line other than valid code");
        }
예제 #15
0
 private void Action_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     ActionClick?.Invoke(this, new EventArgs());
 }
예제 #16
0
 public void Click()
 {
     Seri.Log.Here().Debug(MenuName + " Click");
     ActionClick?.Invoke();
 }
예제 #17
0
 private void runAction_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
 {
     ActionClick?.Invoke(this, EventArgs.Empty);
 }
예제 #18
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);
        }