user9057272
user9057272

Reputation: 457

Winform Webbrowser control Document.All.GetElementsByName not finding element

I am unable to find the desired element when I use

 HtmlElementCollection elements = webBrowser1.Document.All.GetElementsByName("username");

The count is always 0. However, it is able to find the element when I iterate the elements using for loop like this:

 foreach (HtmlElement element in elements)
        {
            if (element.Name == "username")
            {
                try
                {

                }
                catch (Exception)
                {

                    throw;
                }
            }
        }

Why is this? I would prefer to get the desired elements in one line instead of writing foreach loops for all of them.

Upvotes: 0

Views: 76

Answers (0)

Related Questions