Just joined here and started learning vb.net. I searched around, but didn't come across anything. Using Vb.net in Visual Studio with WebBrowser. I have a webpage with a button that I want to click on. The button is displayed 9 times, with the same code. So basically the identical button is displayed multiple times. When I create a function in vb.net to click on the button, it opens up all 9 at once. I would like to open only one at a time. I know in imacros you can get around this problem by assigning position 1, position 2, etc so it clicks on the first occurring one, then the second, etc. Is there a way to do this in vb.net? Thank you.
Here is the code that clicks the button(s)
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
TextBox7.Text = TextBox7.Text + 1
theElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each curElement As HtmlElement In theElementCollection
If InStr(curElement.GetAttribute("value").ToString, "Visit") Then
curElement.InvokeMember("Click")
curElement.InvokeMember("MouseDown")
curElement.InvokeMember("MouseUp")
curElement.InvokeMember("OnClick")
curElement.Focus()
End If
Next
Timer2.Interval = TextBox6.Text
End Sub
Here is the inspect element info of the buttons:
<input class="submit" value="Visit" style="width: 110px; height: 80px; border-radius: 40px; font-size: 27;" type="submit">
id
attribute) or you'll need to assume their identity by their position in the array fromGetElementsByTagName
(which isn't necessarily reliable).