html – Visual Studio – getElementsByTagName() –


Good afternoon,

I am brand new with Visual Basic and am looking to create a program that loads up a browser and logs you in to a specific site.

However, the username and password fields of the web site that I am attempting to log into have no id or name to pull by.

Is there a way to GetElementByClass?
Any help is appreciated. I cannot seem to find much documentation online.

Similar to:


For example, the input box I am trying to get is:

<input type="text" class="gwt-TextBox" maxlength="50" style="width: 180px;">

So far, this is what I have come up with:

Dim theElementCollection As HtmlElementCollection
theElementCollection = WebBrowser1.Document.GetElementsByTagName("input")

For Each curElement As HtmlElement In theElementCollection

Dim controlName As String = curElement.GetAttribute("className").ToString

' This shows classNames of gwt-TextBox and gwt-PasswordTextBox

Dim user As String = "user"
Dim pass As String = "pass"

WebBrowser1.Document.All.GetElementsByName("gwtTextBox").SetAttribute("value", user)
WebBrowser1.Document.All.GetElementsByName("gwt-PasswordTextBox").SetAttribute("value", user)

I am now seeing that SetAttribute is not a member of HtmlElement Collection.

Sorry, as I said this is one of my first VB projects. Please don’t knock me. I am trying to learn.


Please enter your comment!
Please enter your name here