im going to post a bunch of code on webbrowser automating that i used to use when i just started learnign before i got into webrequest
Click A Button
Code:
webbrowser1.Document.All("Button ID").InvokeMember("click")
IF ID Exists
Code:
If WebBrowser1.Document.All("ID") Is Nothing Then
Else
MsgBox("ID exsits")
End If
Click Button Just By Value Of It
Code:
Private Function GetBtnByValue(ByVal value As String) As HtmlElement
For Each d As HtmlElement In Webbrowser1.Document.GetElementsByTagName("input")
If (d.GetAttribute("type").ToLower = asd.Text Or d.GetAttribute("type").ToLower = "submit") Then
If (d.GetAttribute("value") = value) Then
Return d
Exit For
End If
End If
Next
End Function
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
GetBtnByValue("go").InvokeMember("Click")
End Sub
Click Check box
Code:
Dim outer As String = WebBrowser1.Document.All("PersistentCookie").OuterHtml
WebBrowser1.Document.All("Check Box ID").OuterHtml = outer.Remove(outer.Length - 2) + " checked>"
Click all Check box's with same value
Code:
For Each InputBx As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input")
If (InputBx.GetAttribute("type").ToLower = "radio") AndAlso (InputBx.GetAttribute("value").ToLower = "Value Of Check Box") Then
InputBx.InvokeMember("Click")
End If
Next
Fill Textbox In Webbrowser
Code:
For Each HTMLele As HtmlElement In WebBrowser1.Document.All
If HTMLele.Name = "ID" Then
HTMLele.SetAttribute("value", "someemail@somewhere.comValue")
End If
Next
Get Text From Textbox In Webbrowser
Code:
Dim text As String = WebBrowser1.Document.All("Textbox ID).GetAttribute("value")
TextBox1.Text = text
Stop IE Pop ups
Code:
WebBrowser1.ScriptErrorsSuppressed = True
Check URL
Code:
If WebBrowser1.Url.ToString = "URL" Then
webbrowser contains
Code:
If WebBrowser1.DocumentTex*****ntains("Phrase") Then
Else
End If
Webbrowser status
Code:
TextBox1.Text = WebBrowser1.StatusText
Show Page Source
Code:
TextBox1.Text = webBrowser.Document.body.innerHTML
Download Page
Code:
Dim MyWebClient As New System.Net.WebClient()
TextBox1.Text = MyWebClient.DownloadString("URL")