У меня есть простой код, который использует автоматизацию IE для входа на веб-сайт (например, URL1) и затем щелкает ссылку (например, URL2) и ждет, пока новая страница не будет готова, и так далее.
Вот код:
'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!")
Моя проблема в том, что приведенный выше код работал нормально, когда я использовал Windows 7 с IE 10. Но когда я обновлялся до Windows 10 с IE 11, всегда LinkSet2 = LinkSet1 и бесконечный цикл происходит в части 3. Любая помощь будет принята с благодарностью заранее!