/// <summary> /// 获取同一个元素的活动项 /// </summary> /// <param name="constraint"></param> /// <returns></returns> public List <ActionElementBase> GetTheElementActions(WatiN.Core.Constraints.Constraint constraint) { string cs = constraint.ToString(); List <ActionElementBase> aes = new List <ActionElementBase>(); foreach (var o in this) { ActionElementBase ae = o as ActionElementBase; if (ae == null) { continue; } if (ae.GetConstraint().ToString() == cs) { aes.Add(ae); } } return(aes); }
/// <summary> /// Constructs the watin attribute. /// </summary> /// <param name="FindByAttribute">The find by attribute.</param> /// <returns></returns> private bool ConstructWatinAttribute(string FindByAttribute) { if (_ContolStringBuilder.ContainsKey(FindByAttribute)) { string FindByAttributeValue = Convert.ToString(_ContolStringBuilder[FindByAttribute]); // If the string starts with .* then build a regex if (FindByAttributeValue.StartsWith(".*")) { if (WatinAttribute == null) { WatinAttribute = Find.By(FindByAttribute, new Regex(FindByAttributeValue)); } else { WatinAttribute = WatinAttribute.And(Find.By(FindByAttribute, new Regex(FindByAttributeValue))); } } // Assume that it is a string and use string in the attribute else { if ((FindByAttribute.ToLower() == "url") && FindByAttributeValue.StartsWith(@"http://")) { WatinAttribute = Find.ByUrl(new Uri(FindByAttributeValue)); } else if (FindByAttribute.ToLower() == "innertext") { // if the type is custom, we need to split on the : character //string[] splitString = FindByAttributeValue.Split(':'); WatinAttribute = Find.By("innertext", FindByAttributeValue); } else { if (WatinAttribute == null) { WatinAttribute = Find.By(FindByAttribute, FindByAttributeValue); } else { WatinAttribute = WatinAttribute.And(WatinAttribute = Find.By(FindByAttribute, FindByAttributeValue)); } } } return true; } // If we haven't matched an attribute, return false. return false; }