I have a simple code that uses the IE automation to login to a website (e.g., URL1) and then clicking on a link (e.g., URL2) and waiting until the new page gets ready and so on. Here is the code:
'Part 1: Navigating to URL1
IE = CreateObject("InternetExplorer.Application")
IE.visible = True
IE.Navigate(URL1)
Do Until IE.ReadyState = tagREADYSTATE.READYSTATE_COMPLETE
Application.DoEvents()
Loop
LinkSet1 = IE.document.all'Storing the current page's links only to help asking my question clearer :)
'Part 2: Entering user name and password and submit
IE.Document.All("UserNameElementID").InnerText = MyUserName
IE.Document.All("PasswordElementID").InnerText = MyPassword
IE.Document.All("SubmitElementID").click
Do Until IE.ReadyState = tagREADYSTATE.READYSTATE_COMPLETE
Application.DoEvents()
Loop
'Part 3: Search through links to detect a special id on the second page (URL2)
LinkFound = False
Do Until LinkFound
LinkSet2 = IE.document.all'Storing the new page's links only to help asking my question clearer :)
For Each Link In IE.document.all
If InStr(Link.id, "MYSecondURL_id") > 0 Then
LinkFound = True
Exit For
End If
Next
Loop
'Part 4: Send a message to show that the second URL is found
MsgBox("Page loaded completely!")
My problem is that the above code worked finely when I used Windows 7 with IE 10. But when I updated to Windows 10 with IE 11, always LinkSet2 = LinkSet1 and an infinite loop occurs at Part 3. Any help would be appreciated in advance!