I wrote the below VBA code to automate log in to a third party application. When i ran the below code it only opens Internet explorer browser and navigate to the link then do nothing.
here is my code:
Sub Login_Aravo()
Dim ie
Dim sURL As String
On Error GoTo Err_Clear
sURL = "https://demo.aravo.com/"
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate sURL
Do
' Wait till the Browser is loaded
Loop Until ie.readyState = READYSTATE_COMPLETE
ie.Document.all.Item("j_username").Value = "Nothing" 'Enter your username here
ie.Document.all.Item("j_password").Value = "Nothing" 'Enter your password here
ie.Document.all.Item("login").Click
' oBrowser.Refresh ' Refresh If Needed
Err_Clear:
If Err <> 0 Then
'Debug.Assert Err = 0
Err.Clear
Resume Next
End If
End Sub
Your help will be much appreciated.
Thanks
Arup
Your code works if you step through it slowly.
The issue is that you are loading a page that redirects, so it is falsely triggering the READYSTATE complete after the first page is loaded.
The easiest way to correct for this is to just load the page you ultimately end up loading. If you change your sURL to this:
sURL = "https://demo.aravo.com/aems/login.do"the code works perfectly.Alternately, you could make a secondary loop after your first loop that waits to be sure your login-page has loaded. Something like this: