Пример #1
0
            private void InitLabelIdsWithMatchingText(Element element)
            {
                labelIdsWithMatchingText = new Dictionary <string, bool>();

                var domContainer = element.DomContainer;

                var labels = domContainer.Labels.Filter(e =>
                {
                    var text = e.Text;
                    return(!string.IsNullOrEmpty(text) && StringComparer.AreEqual(text.Trim(), labelText));
                });

                foreach (var label in labels)
                {
                    var forElementWithId = label.For;
                    labelIdsWithMatchingText.Add(forElementWithId, true);
                }
            }
        private void InitLabelIdsWithMatchingText(IHTMLElement element)
        {
            labelIdsWithMatchingText = new Hashtable();

            IHTMLDocument2         htmlDocument  = (IHTMLDocument2)element.document;
            IHTMLElementCollection labelElements = (IHTMLElementCollection)htmlDocument.all.tags(ElementsSupport.LabelTagName);

            // Get the list of id's of controls that these labels are for
            for (int i = 0; i < labelElements.length; i++)
            {
                IHTMLElement label = (IHTMLElement)labelElements.item(i, null);
                // Store the id if there is a label text match
                if (StringComparer.AreEqual(label.innerText.Trim(), labelText))
                {
                    string htmlFor = ((IHTMLLabelElement)label).htmlFor;
                    labelIdsWithMatchingText.Add(htmlFor, htmlFor);
                }
            }
        }
Пример #3
0
            private void InitLabelIdsWithMatchingText(Element element)
            {
                labelIdsWithMatchingText = new Dictionary <string, bool>();

                DomContainer domContainer = element.DomContainer;

                LabelCollection labels = domContainer.Labels.Filter(e =>
                {
                    string text = e.Text;
                    if (string.IsNullOrEmpty(text))
                    {
                        return(false);
                    }
                    return(StringComparer.AreEqual(text.Trim(),
                                                   labelText));
                });

                foreach (Label label in labels)
                {
                    string forElementWithId = label.For;
                    labelIdsWithMatchingText.Add(forElementWithId, true);
                }
            }