I am trying to open a site. In that site there is a download link which when clicked, causes a pop-pup named "File Download" to open which has 3 options: open, save and cancel where currently cancel is selected. If i click save then it opens another pop up where i have to click save. I am trying to automate this using vb script. Code:
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "www.abc.com"
Do While IE.Busy
WScript.Sleep 100
Loop
Set Links = IE.document.getElementsByTagName("a")
For Each Link In Links
If InStr(1, Link.href, "?task=downloadFile", vbTextCompare) > 0 Then
IE.Navigate Link.href
Do While IE.Busy
WScript.Sleep 100
Loop
Set WshShell = CreateObject("WScript.Shell")
WScript.Sleep 1000
WshShell.Sendkeys "{TAB}"
WScript.Sleep 1000
WshShell.Sendkeys "{TAB}"
WScript.Sleep 1000
WshShell.Sendkeys "{TAB}"
WScript.Sleep 1000
WshShell.Sendkeys "{TAB}"
WScript.Sleep 1000
WshShell.Sendkeys "{ENTER}"
WshShell.Sendkeys "{TAB}"
WScript.Sleep 1000
WshShell.Sendkeys "{ENTER}"
Exit For
End If
Next
This code is not working as some random windows are getting selected. Kindly help