Beispiel #1
0
        private string HandleCompoent(JObject scriptInfo)
        {
            string methodNanme = "";

            string tradeCode     = scriptInfo.GetValue("tradeCode").ToString();
            string pageCode      = scriptInfo.GetValue("pageCode").ToString();
            string compoentId    = scriptInfo.GetValue("compoentId").ToString();
            string compoentValue = scriptInfo.GetValue("compoentValue").ToString();
            string action        = scriptInfo.GetValue("action").ToString();
            string compoentType  = scriptInfo.GetValue("compoentType").ToString();

            BrowserUntils browserUntils = BrowserUntils.GetBrowser(tradeCode, pageCode);

            methodNanme = compoentType + action;

            string className = "ABCAgreeAutoTestPluging4.Controller.Trade.ScriptExecute";

            Type type = Type.GetType(className);

            object obj = System.Activator.CreateInstance(type);                                        //方法或构造函数的对象

            object[] parameters = new object[] { pageCode, compoentId, compoentValue, browserUntils }; //调用的方法或构造函数的参数列表

            //获取方法信息
            MethodInfo method = type.GetMethod(methodNanme, new Type[] { typeof(string), typeof(string), typeof(string), typeof(BrowserUntils) });

            return(method.Invoke(obj, parameters).ToString());
        }
        /// <summary>
        /// 操作组件信息
        /// </summary>
        /// <param name="tradeMessage"></param>
        /// <returns></returns>
        public JObject HandleCompoent(JObject tradeMessage)
        {
            string itemCode = tradeMessage.GetValue("itemCode").ToString();

            string pageCode = tradeMessage.GetValue("pageCode").ToString();

            string relation = tradeMessage.GetValue("relation").ToString();

            string executeTime = "";

            bool result = true;

            logger.Info("开始操作组件");

            browserUntils = BrowserUntils.GetBrowser(transCode, pageCode);

            logger.Info("获取浏览器对象");

            if (CheckPage(transCode, pageCode) && CheckCompoent(transCode, pageCode, itemCode))
            {
                if (tradeMessage.GetValue("isscreen").ToString().Equals("Y"))
                {
                    //截图
                    ScreenShot.Shot(browserUntils.browser);
                }
                if (relation != "")
                {
                    //执行表达式相关操作
                    HandleRelationExpression(relation);
                }
                if (tradeMessage.Property("resultMap") != null && tradeMessage.GetValue("resultMap").ToString() != "")
                {
                    //处理预期结果
                    ExpectedResult expectedResult = new ExpectedResult(browserUntils);

                    result = expectedResult.CheckExpectedResult(tradeMessage);
                }

                DateTime startTime = DateTime.Now;
                ExecuteCompoent(tradeMessage);
                DateTime endTime = DateTime.Now;
                executeTime = (endTime - startTime).Milliseconds.ToString();//操作组件的时间

                tradeMessage.Add("direction", executeTime);
                tradeMessage.Add("checkResult", result);
            }
            else
            {
                Property.executeResult = false;
            }
            return(tradeMessage);
        }
Beispiel #3
0
        public string HandleConpoentByScriptt(JObject scriptInfo)
        {
            string result = "";

            //停止
            if (scriptInfo.Property("stopPlugin") != null && scriptInfo.GetValue("stopPlugin").ToString() != "")
            {
                Property.PerformaceMark = false;

                return(StopPlugin());
            }
            //打开交易
            if (scriptInfo.Property("openTrade") != null && scriptInfo.GetValue("openTrade").ToString() != "")
            {
                return(OpenTrade(scriptInfo.GetValue("openTrade").ToString()).ToString());
            }
            //关闭交易
            if (scriptInfo.Property("closeTrade") != null && scriptInfo.GetValue("closeTrade").ToString() != "")
            {
                return(CloseTrade(scriptInfo.GetValue("closeTrade").ToString()));
            }
            //截图
            if (scriptInfo.Property("isScreenShot") != null && scriptInfo.GetValue("isScreenShot").ToString() != "")
            {
                browserUntils = BrowserUntils.GetBrowser(scriptInfo.GetValue("transCode").ToString(), scriptInfo.GetValue("pageCode").ToString());

                //截图
                ScreenShot.Shot(browserUntils.browser);

                return(browserUntils.ExecuteScript("截图的js语句"));
            }

            DateTime startTime = DateTime.Now;

            result = HandleCompoent(scriptInfo);
            DateTime endTime     = DateTime.Now;
            string   executeTime = (endTime - startTime).Milliseconds.ToString();//操作组件的时间

            scriptInfo.Add("direction", executeTime);
            scriptInfo.Add("checkResult", result);

            Property.scriptMessage.Add(scriptInfo);//将脚本中信息存储起来


            return(result);
        }
        public bool CheckPage(string tansCode, string pageCode)
        {
            BrowserUntils.GetBrowser(tansCode, pageCode).ExecuteScript("");

            throw new NotImplementedException();
        }
 private string GetRelationValue(string tradeCode, string pageCode, string compoentId)
 {
     return(BrowserUntils.GetBrowser(tradeCode, pageCode).ExecuteScript("function foo(){return window.findVueByName('" + pageCode + "').$refs." + compoentId + ".value};foo();"));
 }