B
BobRoyAce
I am attempting to use a WebBrowser on a Windows Form application, in
a situation where I am wanting to automate the following:
1) Click on all checkboxes on page
2) Click on link to go to new page
I have successfully coded the above two steps.
Now, what I want to do is do the above two steps a repeated number of
times. So, I try to do it in a loop. The problem is, step 1 attempts
to run before step 2 has completed (i.e. the new page has loaded).
How can I change code so that step 1 won't run until step 2 has
completed?
Private Sub GetEmAll()
For i As Integer = 1 To 10
GetContactsOnCurrentPage()
'*** WHAT SHOULD I DO HERE?
Next
End Sub
Private Sub GetContactsOnCurrentPage()
' Check all checkboxes on page
Dim oCheckBoxes As HtmlElementCollection = GetElements()
For Each oElement As HtmlElement In oCheckBoxes
If (oElement.OuterHtml.Contains("dgSelect_ct")) Then
oElement.InvokeMember("Click")
End If
Next
' Click on link to go to next page
Dim oNext As HtmlElement =
WebBrowser1.Document.GetElementById("btnNextPage")
oNext.InvokeMember("Click")
End Sub
a situation where I am wanting to automate the following:
1) Click on all checkboxes on page
2) Click on link to go to new page
I have successfully coded the above two steps.
Now, what I want to do is do the above two steps a repeated number of
times. So, I try to do it in a loop. The problem is, step 1 attempts
to run before step 2 has completed (i.e. the new page has loaded).
How can I change code so that step 1 won't run until step 2 has
completed?
Private Sub GetEmAll()
For i As Integer = 1 To 10
GetContactsOnCurrentPage()
'*** WHAT SHOULD I DO HERE?
Next
End Sub
Private Sub GetContactsOnCurrentPage()
' Check all checkboxes on page
Dim oCheckBoxes As HtmlElementCollection = GetElements()
For Each oElement As HtmlElement In oCheckBoxes
If (oElement.OuterHtml.Contains("dgSelect_ct")) Then
oElement.InvokeMember("Click")
End If
Next
' Click on link to go to next page
Dim oNext As HtmlElement =
WebBrowser1.Document.GetElementById("btnNextPage")
oNext.InvokeMember("Click")
End Sub