im trying to click a button in my webbrowser.
i have created a button in my form to click that button, but it gives me error on this line
Dim elements As HtmlElementCollection = custombrowser.Document.All
could it be that the website is blocking me for clicking that button?? here is my custom browser class:
Public Class custombrowser
Inherits WebBrowser
Public Sub New()
Me.ScriptErrorsSuppressed = True
End Sub
Private Sub docomplited() Handles Me.DocumentCompleted
Dim TP As TabPage = Me.Tag
My.Settings.ddd = TP.Text
If Me.DocumentTitle.Length > 15 Then
TP.Text = Me.DocumentTitle.Substring(0, 14) & ""
Else
TP.Text = Me.DocumentTitle
End If
My.Settings.ddd = TP.Text
End Sub
Private Sub custombrowser_LocationChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LocationChanged
End Sub
Private Sub custombrowser_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles Me.Navigated
Form1.Label1.Text = Me.Url.ToString
End Sub
End Class
The buttton code :
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If custombrowser.document IsNot Nothing Then
Dim elements As HtmlElementCollection = custombrowser.Document.All
For Each webpageelement As HtmlElement In elements
custombrowser.Document.All("click").InvokeMember("click")
If webpageelement.GetAttribute("class") = "click" Then
webpageelement.InvokeMember("click")
End If
Next
End If
End Sub