private IHTMLLabelElement GetLabel(IHTMLElement element) { string id = element.id; if (string.IsNullOrWhiteSpace(id)) { return(null); } IHTMLElementCollection elements = ((IHTMLDocument3)element.document).getElementsByTagName("label"); for (int i = 0; i < elements.length; i++) { IHTMLLabelElement label = elements.item(Type.Missing, i); if (!string.IsNullOrWhiteSpace(label.htmlFor)) { if (label.htmlFor == id) { return(label); } } } return(null); }
public void ExplicitFormIdIgnoredOnNonFormReassociateable() { CQ cq = CQ.Create("<form id=a><div><label form=b></div></form><form id=b></form>"); IHTMLLabelElement label = cq["label"].FirstElement() as IHTMLLabelElement; Assert.IsNotNull(label); Assert.IsNotNull(label.Form); Assert.AreEqual("a", label.Form.Id); }
public static string ByLabel(IHTMLElement element) { IHTMLLabelElement label = element as IHTMLLabelElement; if (null == label) { return(string.Empty); } return(string.Format("label={0}", element.innerText.Trim())); }
public Label(DomContainer domContainer, IHTMLLabelElement labelElement) : base(domContainer, domContainer.NativeBrowser.CreateElement(labelElement)) { }