I try to get automatic click on a button on a page on my website I have try multiple things and i can not get out of this exception This is My code Well wen i press the button1 its come an error I describe below code
Public Class Form5
Dim CheckButton, skip_ad_button As HtmlElement
Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
WebBrowser1.ObjectForScripting = True
WebBrowser1.ScriptErrorsSuppressed = True
End Sub
Private Sub Form5_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
skip_ad_button = WebBrowser1.Document.GetElementById("skip_ad_button")
CheckButton = WebBrowser1.Document.GetElementById("skip_ad_button")
If Not skip_ad_button Is Nothing Then
skip_ad_button.InnerText = "skip_ad_button" 'Replace testID by the ID you want
End If
If Not CheckButton Is Nothing Then
'some code here
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
WebBrowser1.Navigate("http:\\mediaads.eu/proxy")
End Sub
End Class
This is the error
System.NotSupportedException was unhandled by user code HResult=-2146233067 Message=Property is not supported on this type of HtmlElement. Source=System.Windows.Forms StackTrace: at System.Windows.Forms.HtmlElement.set_InnerText(String value) at WindowsApplication1.Form5.WebBrowser1_DocumentCompleted(Object sender,
WebBrowserDocumentCompletedEventArgs e) in \Documents\Visual Studio 2012\Projects\WindowsApplication1\WindowsApplication1\Form5.vb:line 23