public static Element Locate(this IElementsContainer arg, AttributeConstraint findBy) { Element result = arg.Element(findBy); if (result.Exists) { return(result); } throw new WatiNException(string.Format("Cannot locate element that matches contraint: {0}", findBy)); }
/// <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(".*")) { WatinAttribute = 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 { WatinAttribute = Find.By(FindByAttribute, FindByAttributeValue); } } return true; } // If we haven't matched an attribute, return false. return false; }
protected Element Locate(AttributeConstraint constraint) { return(ie.Locate(constraint)); }
public static Element Locate(this Element arg, AttributeConstraint findBy) { var container = (IElementsContainer)arg; return(container.Locate(findBy)); }