Beispiel #1
0
        /// <summary>
        /// 独立元素
        /// </summary>
        /// <param name="sigEle"></param>
        private IWebElement FindSigEle(SingleWebEle sigEle)
        {
            IWebElement sigElement = null;

            try
            {
                ReadOnlyCollection <IWebElement> eles = GetWebElesInHtml(sigEle.Locator, sigEle.Value);
                if (eles == null || eles.Count == 0)
                {
                    ComArgs.RoLog.WriteLog(LogStatus.LFail, $"FindSigEle查询到0个控件,控件:{sigEle.Value}");
                }
                else
                {
                    if (eles.Count == 1)
                    {
                        sigElement = eles[0];
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(sigEle.Index))
                        {
                            sigElement = eles[Convert.ToInt32(sigEle.Index) - 1];
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ComArgs.RoLog.WriteLog(LogStatus.LExpt, $"私有方法FindSigEle发生异常,sigID:{sigEle.Id}", e.ToString());
            }

            return(sigElement);
        }
Beispiel #2
0
        /// <summary>
        /// 返回SingleWebEle
        /// </summary>
        /// <param name="sigXElement"></param>
        /// <returns></returns>
        public SingleWebEle GetSingleWebEle(XElement sigXElement)
        {
            SingleWebEle singleWebEle = new SingleWebEle();

            XElement valueinfo = sigXElement.Element(XName.Get("valueinfo", ComArgs.RoiStr));

            singleWebEle.Id = sigXElement.Attribute(XName.Get("id", ComArgs.RoiStr))?.Value ?? Empty;
            if (valueinfo != null)
            {
                singleWebEle.Index   = valueinfo.Attribute(XName.Get("index", ComArgs.RoiStr))?.Value ?? Empty;
                singleWebEle.Locator = valueinfo.Attribute(XName.Get("locator", ComArgs.RoiStr))?.Value ?? Empty;
                singleWebEle.Value   = valueinfo.Value;
            }

            return(singleWebEle);
        }
Beispiel #3
0
        /// <summary>
        /// 元素协助方法,对已存在的roi/tci文件进行解析
        /// </summary>
        /// <param name="sigconf">配置实体类</param>
        /// <param name="path">实际路径</param>
        private void WebElementAssist(ConfigurationFile sigconf, string path)
        {
            ElementReference elementReference = new ElementReference();

            try
            {
                //读取roi/tci文件
                XDocument doc = XDocument.Load(path);
                //提取根节点
                XElement rootEle = doc.Element(XName.Get("roi", ComArgs.RoiStr));
                //获取meta节点
                XElement metaele = rootEle?.Element(XName.Get("meta", ComArgs.RoiStr));
                if (metaele != null)
                {
                    foreach (XElement sigXElement in metaele.Elements())
                    {
                        string name = sigXElement.Name.LocalName;
                        switch (name)
                        {
                        case "sigele":

                            SingleWebEle sig = elementReference.GetSingleWebEle(sigXElement);
                            ElementDic.Add($"{sigconf.Id}.{sig.Id}", sig);     //添加到字典
                            break;

                        case "cpxele":
                            List <CpxWebELe> cpx = elementReference.GetCpxWebELe(sigXElement);
                            foreach (CpxWebELe variable in cpx)
                            {
                                ElementDic.Add($"{sigconf.Id}.{variable.Id}", variable);     //添加到字典
                            }
                            break;

                        case "superset":

                            foreach (XElement oneeleFir in sigXElement.Elements(XName.Get("subset", ComArgs.RoiStr)))
                            {
                                foreach (XElement oneeleSec in oneeleFir.Elements())
                                {
                                    string nameSec = oneeleSec.Name.LocalName;
                                    switch (nameSec)
                                    {
                                    case "sigele":

                                        SingleWebEle sigSec = elementReference.GetSingleWebEle(oneeleSec);
                                        ElementDic.Add($"{sigconf.Id}.{sigSec.Id}", sigSec);         //添加到字典
                                        break;

                                    case "cpxele":
                                        List <CpxWebELe> cpxSec = elementReference.GetCpxWebELe(oneeleSec);
                                        foreach (CpxWebELe variable in cpxSec)
                                        {
                                            ElementDic.Add($"{sigconf.Id}.{variable.Id}", variable);         //添加到字典
                                        }
                                        break;
                                    }
                                }
                            }

                            break;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ComArgs.RoLog.WriteLog(LogStatus.LExpt, "私有方法ElementAssist发生异常", e.ToString());
            }
        }