Hello,
I am trying to make a program which will login to a website with many different accounts one after another.
The problem I have though is, the documentCompleted event either doesn't run at all or it runs more than once before the page is fully loaded. This causes the application to throw an error because the input fields for the login form are not loaded yet...
Here is the code I have in the document completed event:
If (WebBrowser1.Url.ToString = urlInfo.Text) Then
Dim userEl = WebBrowser1.Document.GetElementById(usernameForm.Text)
userEl.SetAttribute("value", usernameCred.Text)
Dim passEl = WebBrowser1.Document.GetElementById(passForm.Text)
If (usePassFile And passCurLine < passFileLinesCount) Then
passEl.SetAttribute("value", passFileLines(passCurLine))
statusBox.Text = "Trying " & passFileLines(passCurLine) & "..."
passCurLine += 1
Dim allelements As HtmlElementCollection = WebBrowser1.Document.All
For Each element As HtmlElement In allelements
If (element.GetAttribute("id") = loginForm.Text) Then
element.InvokeMember("click")
End If
Next
End If
MsgBox("Ran")
Else
statusBox.Text = "Successfully logged in"
End If
Any help?
Thanks