I'm attempting to
1) click a single checkbox on the loaded page (which should redirect the page in the process)
2) click a URL on the next page
Apparrently the checkbox is beyond my scope because I can't seem to get it to work. There are 5 forms on the page, and the check box is in the 4th (index 3?). Also in that form is a hidden value which is specified before the checkbox name. Here is some code I'm working with:
Code:
Public Class frmMain
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tmpStr As String = "http://localhost/CASE_NUMBER=" & CStr(TextBox1.Text)
wb.Url = New System.Uri(tmpStr)
End Sub
Private Function GetCurrentWebDoc() As MSHTML.HTMLDocument
Try
Return DirectCast(wb.Document, mshtml.HTMLDocument)
Catch ex As Exception
Return Nothing
End Try
End Function
Private Function GetCurrentWebForm() As MSHTML.HTMLFormElement
Try
If GetCurrentWebDoc.forms.length > 0 Then
Return DirectCast(GetCurrentWebDoc.forms.item(3), MSHTML.HTMLFormElement)
Else
Return Nothing
End If
Catch ex As Exception
Return Nothing
End Try
End Function
Private Sub ClickCheckBox()
Dim MyInputElement As MSHTML.HTMLInputElement = DirectCast(GetCurrentWebForm.item("checkBoxName", 3), MSHTML.HTMLInputElement)
MyInputElement.checked = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ClickCheckBox()
End Sub
End Class
Unfortunately I can't really post the HTML I'm working with, but I could cut and past relevant portions if I knew what would help.
Thanks for any suggestions!