Windows 10 Pro
Purchased Enterprise Edition
Ran in chrome Version 63.0.3239.52 (Official Build) beta (64-bit)
Hi, I have set up an imacros vb script to login to a site and download a file - it is working when browser is being ran normally, but when I run it in -silent mode, which is what i would like to do, it is not able to download the file. I am unable to share the website.
ive got the full script running in chrome. When I run the script in silent mode it does download a file but the file is named "download" -- which is the text of the download button, and contains this message:
Code: Select all
<div class="container-fluid">
<div class="tab-content">
<br />
<div class="col-lg-12">
<div class="row">
<div class="well">
<center><b><font color="red"> An error has occurred:</font></b></center>
<center><i> Request not supported this way. </i></center><br />
<p>If you believe your request is valid, please try to submit the request later. </p>
<p>If that does not work please contact [CLIENT at 1-800-CLIENT NUMBER]. You will be asked for the details on
your computing environment, error information, how to reproduce it, and your contact information.</p>
<br />
<button class="btn btn-primary" onclick="history.back()">Back to Previous Page</button>
</div>
</div>
</div>
<br />
</div>
</div>
<script src="/MailBoxWebService/resources/dist/js/jquery-1.11.0.min.js"></script>
<script src="/MailBoxWebService/resources/dist/js/bootstrap.min.js"></script>
</body>
Does anyone know how I can get this to download in silent mode? I am open to using any browser.
Code: Select all
Set M = Nothing
Skip = False
Browser = iim1.iimInit("", True, 300)
Browser = iim1.iimSet("Count", Count)
WScript.Echo("Beginning Loop for File Info and File Download. Current Loop = " & Count & "Of" & Total)
M = "CODE:"
M = "VERSION BUILD=844 RECORDER=CR" + N
M = M + "SET !PLAYBACKDELAY 0.00" + N
M = M + "SET !var1 {{Count}}" + N
M = M + "TAB T=1" + N
M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[2] EXTRACT=TXT" + N
M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[3] EXTRACT=TXT" + N
M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[4] EXTRACT=TXT" + N
M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[5] EXTRACT=TXT" + N
M = M + "ONDOWNLOAD FOLDER=C:\Temp FILE=* WAIT=YES" + N
M = M + "WAIT SECONDS=2" + N
M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[6]/a" + N
M = M + "WAIT SECONDS=5" + N
M = M + "SET !TIMEOUT_STEP 60" + N
Browser = iim1.iimPlayCode(M)
FileName = iim1.iimGetLastExtract(1)
FileDate = iim1.iimGetLastExtract(2)
FileSize = iim1.iimGetLastExtract(3)
FileIteration= iim1.iimGetLastExtract(4)
Code: Select all
<a href="#" class="btn btn-primary" onclick="downloadFile('rebrkso/.history/REBRKSO.RECAIFPL.J2017333.N06019018951513.2017-11-29.0410','REBRKSO','REBRKSO.RECAIFPL.J2017333.N06019018951513');">Download</a>
the full script is
Code: Select all
Option Explicit
Const iM_ElementNotFound = -1300
Const iM_EndOfFile = -1240
Const iM_EvalError = -1340
Const iM_BrowzConnErr = -1340
Const iM_BadParam = -1200
Const iM_Success = 1
Const ForAppending = 8
Const OpenAsASCII = 0
Const CreateIfNotExist = True
Dim Count, Date, Extract, FileName, FileDate, FileSize, FileIteration, i, iMacros, M, objFile, Processed, Skip, FileInfo
Dim WshShell : Set WshShell = CreateObject("WScript.Shell")
Dim iim1 : Set iim1 = CreateObject("iMacros")
Dim Browser : Browser = iim1.iimOpen("-cr", true)
Dim objFso : Set objFso = CreateObject("Scripting.FileSystemObject")
Dim iDayNumber : iDayNumber = DateDiff("d", CDate("1/1/" & Year(Now)), Now) + 1
Dim varLMonth : varLMonth = Month(Now) - 1
Dim varDateFull : varDateFull = Month(Now) & "-" & Day(Now) & "-" & Year(Now)
Dim varOldPW : varOldPW = "Client" & Year(Now) & varLMonth
Dim Output : Output = "C:\temp\Output" & "_" & varDateFull & ".csv"
Dim LogName : LogName = "C:\temp\Client1 iMacros Error log" & varDateFull & ".txt"
Dim DateSearch : DateSearch = "J" & Year(Now) & iDayNumber
Dim CountString : CountString = "Default"
Dim Total : Total = "Default"
Dim FirstRun : FirstRun = "True"
Dim NewMonth : NewMonth = "False"
Dim N : N = vbNewLine
If Len(Day(Now)) = 1 Then varDay = "0" & varDay
If Len(Month(Now)) = 1 Then varMonth = "0" & varMonth
If Day(Now) = 1 Then FirstOfMonth = "True"
If objFSO.FileExists(Output) Then
Set Output = objFSO.OpenTextFile(Output, ForAppending, OpenAsASCII)
FirstRun = False
Else
Set Output = objFSO.CreateTextFile(Output, ForAppending, OpenAsASCII)
If Err <> 0 Then
End If
End If
Browser = iim1.iimSet("DateSearch", DateSearch)
Browser = iim1.iimSet("varOldPW", varOldPW)
M = "CODE:"
M = "VERSION BUILD=844 RECORDER=CR" + N
M = M + "TAB T=1" + N
M = M + "TAB CLOSEALLOTHERS" + N
M = M + "URL GOTO=https://www.website.com/" + N
M = M + "TAG SELECTOR=#httpd_username CONTENT=username" + N
M = M + "TAG SELECTOR=#loginButton" + N
M = M + "SET !ENCRYPTION NO" + N
If NewMonth = "False" Then
M = M + "TAG POS=1 TYPE=INPUT:PASSWORD ATTR=NAME:httpd_password CONTENT=Password{{!NOW:yyyymm}}" + N
M = M + "WAIT SECONDS=1" + N
M = M + "TAG SELECTOR=#loginButton" + N
Else
M = M + "TAG SELECTOR=#httpd_password CONTENT=password{{varOldPW}}" + N
M = M + "ONDIALOG POS=1 BUTTON=OK CONTENT=" + N
M = M + "TAG SELECTOR=#httpd_username CONTENT=username" + N
M = M + "TAG SELECTOR=#loginButton" + N
M = M + "TAG XPATH=""//*[@id='home']/div[3]/div/div/input" + N
M = M + "TAG POS=1 TYPE=INPUT:PASSWORD ATTR=NAME:currentPassword CONTENT={{varOldPw}}" + N
M = M + "TAG POS=1 TYPE=INPUT:PASSWORD ATTR=NAME:newPassword CONTENT={{!NOW:yyyymm}}" + N
M = M + "TAG POS=1 TYPE=INPUT:PASSWORD ATTR=NAME:confirmPassword CONTENT={{!NOW:yyyymm}}" + N
M = M + "TAG POS=1 TYPE=INPUT:SUBMIT ATTR=NAME:changepassword" + N
M = M + "TAG SELECTOR=#serviceList>A>IMG" + N
M = M + "URL GOTO=https://website.com/MailBoxWebService/webmailbox/home" + N
End If
M = M + "WAIT SECONDS=2" + N
M = M + "TAG SELECTOR=""#serviceList>A>IMG""" + N
M = M + "TAG POS=1 TYPE=B ATTR=TXT:Mail<SP>Box" + N
M = M + "TAG POS=1 TYPE=A ATTR=TXT:MyCompany<SP>and<SP>MyCompany<SP>Outbox<SP>(REBRKSO)" + N
M = M + "SET !TIMEOUT_PAGE 180" + N
M = M + "SET !TIMEOUT_STEP 100" + N
M = M + "EVENT TYPE=CLICK SELECTOR=""HTML>BODY>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV>FORM>DIV>DIV:nth-of-type(2)>LABEL>INPUT"" BUTTON=0" + N
M = M + "EVENTS TYPE=KEYPRESS SELECTOR=""HTML>BODY>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV>FORM>DIV>DIV:nth-of-type(2)>LABEL>INPUT"" CHARS=""{{DateSearch}}""" + N
'M = M + "TAG POS=1 TYPE=INPUT:SEARCH FORM=NAME:downloadFiles ATTR=* CONTENT={{DateSearch}}" + N
M = M + "TAG SELECTOR=#file_details_info EXTRACT=TXT" + N
M = M + "SET !TIMEOUT_STEP 25" + N
Browser = iim1.iimPlayCode(M)
CountString = iim1.iimGetLastExtract(1)
Total = trim(split(CountString, " ")(5))
For Count = 1 to Total
Set M = Nothing
Skip = False
Browser = iim1.iimInit("", True, 300)
Browser = iim1.iimSet("Count", Count)
WScript.Echo("Beginning Loop for File Info and File Download. Current Loop = " & Count & "Of" & Total)
M = "CODE:"
M = "VERSION BUILD=844 RECORDER=CR" + N
M = M + "SET !PLAYBACKDELAY 0.00" + N
M = M + "SET !var1 {{Count}}" + N
M = M + "TAB T=1" + N
M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[2] EXTRACT=TXT" + N
M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[3] EXTRACT=TXT" + N
M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[4] EXTRACT=TXT" + N
M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[5] EXTRACT=TXT" + N
M = M + "ONDOWNLOAD FOLDER=C:\Temp FILE=* WAIT=YES" + N
M = M + "WAIT SECONDS=2" + N
M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[6]/a" + N
M = M + "WAIT SECONDS=5" + N
M = M + "SET !TIMEOUT_STEP 60" + N
Browser = iim1.iimPlayCode(M)
FileName = iim1.iimGetLastExtract(1)
FileDate = iim1.iimGetLastExtract(2)
FileSize = iim1.iimGetLastExtract(3)
FileIteration= iim1.iimGetLastExtract(4)
Wscript.Echo("File Name = " & FileName)
Wscript.Echo("File Date = " & FileDate)
Wscript.Echo("File Size = " & FileSize)
Wscript.Echo("File Iteration = " & FileIteration)
If objFSO.FileExists(FileName) Then
Count = Count + 1
Else
If Browser = iM_Success Then
FileInfo = FileName & "," & FileDate & "," & FileSize & "," & FileIteration
Count = Count + 1
Output.Write(FileInfo) & vbCrLf
ElseIf Browser = iM_BadParam Then
Count = Count + 1
FileInfo = iim1.iimGetLastExtract(1)
Else
End If
End If
Next
Set M = Nothing
Browser = iim1.iimInit("-cr", false, 300)
Browser = iim1.iimSet("Count", Count)
M = "CODE:"
M = "VERSION BUILD=844 RECORDER=CR" + N
M = M + "TAG POS=1 TYPE=INPUT:SEARCH ATTR=ARIA-CONTROLS:file_details" + N
M = M + "TAG POS=1 TYPE=H4 ATTR=TXT:Files<SP>Available<SP>for<SP>Download<SP>under<SP>mailbox<SP>REBRKSO" + N
M = M + "TAG POS=1 TYPE=A ATTR=TXT:Account" + N
M = M + "TAG POS=1 TYPE=SPAN ATTR=CLASS:glyphicon<SP>glyphicon-log-out" + N
Browser = iim1.iimPlayCode(M)
Output.Close 'Close the CSV File
Browser = iim1.iimExit() 'Close the Browser
WScript.Echo("Data Extracted : " & FileInfo)
If Count <> Total Then WScript.Echo("Proceeding to next iteration (" & Count & ")")
If Count = Total Then WScript.Echo("All iterations completed (" & Count & ")" & N & "Closing browser, input file & output file) ")
If Browser < 0 then 'If there is an error, take a screenshot, send email, and stop processing
Browser = iim1.iimTakeBrowserScreenshot ("./screenshot of Discover Error " & Hour(Now)&Minute(Now)&Second(Now) & ".png")
Output.Close
Browser = iim1.iimExit()
If iscr < 0 then
'Need to Send an Email
End If
End If
WScript.Echo(vbNewLine & "------------ Processing Complete ------------")
WScript.Quit()
Thanks for any help!