Exemple #1
0
 public IEElement(Browser browser, HtmlAgilityPack.HtmlNode node)
 {
     Browser    = browser;
     this.node  = node;
     this.xpath = node.XPath.Replace("[1]", "");
     //var Element = GetLiveElement(node, browser);
     //RawElement = Element;
     ClassName = string.Join(" ", node.GetClasses());
     Id        = node.Id;
     TagName   = node.Name.ToLower();
     Name      = "";
     try
     {
         if (node.Attributes.Contains("Name"))
         {
             Name = node.Attributes["Name"].Value;
         }
     }
     catch (Exception)
     {
     }
     if (TagName == "input")
     {
         if (node.Attributes.Contains("type"))
         {
             Type = node.Attributes["type"].Value.ToLower();
         }
         else
         {
             Type = "text";
         }
     }
     IndexInParent = -1;
     if (node.ParentNode != null)
     {
         var children = node.ParentNode.ChildNodes;
         for (int i = 0; i < children.Count; i++)
         {
             if (children[i].Equals(node))
             {
                 IndexInParent = i; break;
             }
         }
     }
 }
        public static (Classificator.BuildingEnum, int) UpgradeBuildingGetInfo(HtmlAgilityPack.HtmlNode node)
        {
            var classes = node.GetClasses().ToList();

            int level    = -1;
            var building = Classificator.BuildingEnum.Site;

            var lvlClass = classes.FirstOrDefault(x => x.StartsWith("level"));

            if (lvlClass != null)
            {
                level = int.Parse(lvlClass.Replace("level", ""));
            }

            var buildingClass = classes.FirstOrDefault(x => x.StartsWith("gid"));

            if (buildingClass != null)
            {
                var num = (int)Parser.RemoveNonNumeric(buildingClass.Replace("gid", ""));
                building = (Classificator.BuildingEnum)num;
            }

            return(building, level);
        }