public WebControl(Guid id, WebControlType type, Dictionary <string, string> style, Dictionary <string, string> props) { Id = id.ToString(); Type = type; Styles = style; Properties = props; }
/// <summary> /// Gets the a Web control with matching tag name in certain index, /// In this indexer you can select from list, if you're not fammilier with the tag names /// </summary> /// <example> /// Both saples below will click the about link the first example /// looks for the 3rd UNKNOWN (any) tag and the second goes through all links /// and clicks on the third. /// <code> /// HTMLLink about = Browser.This.CurrentPage.Body["CENTER", 1]["FONT", 1][WebControlType.UNKNOWN, 3] as HTMLLink; /// about.Click(); /// /// //or /// /// HTMLLink about = Browser.This.CurrentPage.Body["CENTER", 1]["FONT", 1][WebControlType.A, 3] as HTMLLink; /// about.Click(); /// </code> /// </example> /// <param name="type"></param> /// <param name="localIndex"></param> /// <returns>If tag and index found return a WebControl, else return null</returns> public virtual WebControl this[WebControlType type, int localIndex] { get { if (Exists) { IHTMLElementCollection elements = (IHTMLElementCollection)htmlElement.children; // new PropertyCondition(AutomationElement.IsControlElementProperty, true)); int idxCounter = 1; foreach (IHTMLElement element in elements) { if (element.tagName.ToLower().Contains(type.ToString().ToLower()) || type == WebControlType.UNKNOWN) { if (idxCounter == localIndex) { return(GetControlByType(element)); } else { idxCounter++; } } } } return(new WebNullControl()); } }