Hello,
So im in the process of completing an html form but am having some issues clicking the submit button after the form is completed.
The form validates the username and updates other fields. I'm looking for a way to wait for the form to validate the name then click submit.
I've tried verifying that the name field is not empty.
'This code does click the button when assigned to a VB.net button.
Any help is greatly appreciated.
So im in the process of completing an html form but am having some issues clicking the submit button after the form is completed.
Code:
Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
Dim allelements As HtmlElementCollection = WebBrowser1.Document.All
For Each webpageelement As HtmlElement In allelements
If (webpageelement.GetAttribute("ID").Contains("sys_display.incident.caller_id")) Then
webpageelement.SetAttribute("value", "MyUserName")
webpageelement.Focus()
webpageelement.InvokeMember(Keys.Tab)
End If
Next
For Each webpageelement As HtmlElement In allelements
If (webpageelement.GetAttribute("ID").Contains("sys_readonly.incident.caller_id.user_name")) Then
webpageelement.InvokeMember("Click")
End If
Next
For Each webpageelement As HtmlElement In allelements
If (webpageelement.GetAttribute("ID").Contains("incident.short_description")) Then
webpageelement.SetAttribute("value", "Test")
End If
Next
For Each webpageelement As HtmlElement In allelements
If (webpageelement.GetAttribute("id").Contains("incident.comments")) Then
webpageelement.Focus()
webpageelement.SetAttribute("value", "Test")
webpageelement.InvokeMember("Click")
End If
Next
For Each webpageelement As HtmlElement In allelements
If (webpageelement.GetAttribute("ID").Contains("incident.assignment_group")) Then
webpageelement.SetAttribute("value", "MyGroup")
webpageelement.Focus()
webpageelement.InvokeMember(Keys.Tab)
End If
Next
'This is my submit button
For Each webpageelement As HtmlElement In allelements
If (webpageelement.GetAttribute("ID").Contains("sysverb_insert")) Then
webpageelement.InvokeMember("Click")
End If
Next
I've tried verifying that the name field is not empty.
Code:
Dim name = WebBrowser1.Document.GetElementById("sys_display.incident.caller_id")
If name IsNot Nothing Then
For Each webpageelement As HtmlElement In allelements
If (webpageelement.GetAttribute("ID").Contains("sysverb_insert")) Then
webpageelement.InvokeMember("Click")
End If
Next
End If
Code:
For Each webpageelement As HtmlElement In allelements
If (webpageelement.GetAttribute("ID").Contains("sysverb_insert")) Then
webpageelement.InvokeMember("Click")
End If
Next