I have come across one obstacle when using the looping in imacros chrome version. I hope some one can help me out.
I am now trying to download some data concerning several districts and date. I have the the specific districts and dates stored in a .csv file. And I want to run the iMacros loop according to the index in that .csv file to automatically download those data. The following is the code in iMacros.
VERSION BUILD=844 RECORDER=CR
TAB OPEN
WAIT SECONDS=2
TAB T=2
WAIT SECONDS=2
SET !DATASOURCE Datasource.csv
SET !DATASOURCE_COLUMNS 3
SET !DATASOURCE_LINE {{!LOOP}}
URL GOTO=http://202.39.224.50/FMS_Plic/#
WAIT SECONDS=2
TAG POS=1 TYPE=A ATTR=TXT:MonitorRecord
WAIT SECONDS=5
FRAME F=2
TAG POS=1 TYPE=A ATTR=ID:ddlDC_Arrow
TAG POS=1 TYPE=LI ATTR=TXT:DC1
WAIT SECONDS=10
TAG POS=1 TYPE=A ATTR=ID:ddlCar_Arrow
TAG POS=1 TYPE=LI ATTR=TXT:{{!COL1}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:form1 ATTR=ID:date1 CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:form1 ATTR=ID:btnQuery
WAIT SECONDS=60
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:form1 ATTR=ID:Cexcel
WAIT SECONDS=60
TAB CLOSE
WAIT SECONDS=2
The code of iMacros itself has nothing wrong and it runs smoothly. However, the problem is that the website is unstable, crashing from time to time. If it crashes, the iMacros will be unable to find the related information the report errors, then exit. Due to the loop has to go from 1 to 300000, which takes a lot of time if I do it manually.
So I am looking for a solution that fix this. If there is an error, restart the current loop, not skip(I noticed that someone suggest to use !ERRORIGNORE. But if I use that, the current loop will be skipped and that is not what I expect). And from some instructions online, javascript seems to be a solution. However, I know nothing about java as well as how to use javascript together with iMacros. If this can be solved on other browsers other than Chrome, please also let me know what to do.
I sincerely appreciate any suggestions on this! Thanks a lot!:)
I think this issue can be solved not only with 'iMacros for Firefox' (& its JavaScript Scripting Interface) but with 'iMacros for Chrome' as well. Suggest using the !ERRORIGNORE
. Let's define the myLoop
variable in order to restart the current loop when an error has appeared. I assume that it's equivalent to not finding the text of the element TAG POS=1 TYPE=A ATTR=TXT:MonitorRecord
. Here is a code to try and improve:
TAB OPEN
WAIT SECONDS=2
TAB T=2
WAIT SECONDS=2
SET myLoop EVAL("if ('{{myLoop}}' == '__undefined__') ml = 1; else if ('{{!EXTRACT}}' == '' || '{{!EXTRACT}}' == '#EANF#') ml = ml; else ml = ++ml; ml;")
SET !EXTRACT NULL
SET !DATASOURCE Datasource.csv
SET !DATASOURCE_COLUMNS 3
SET !DATASOURCE_LINE {{myLoop}}
SET !ERRORIGNORE YES
URL GOTO=http://202.39.224.50/FMS_Plic/#
WAIT SECONDS=2
TAG POS=1 TYPE=A ATTR=TXT:MonitorRecord EXTRACT=TXT
TAG POS=1 TYPE=A ATTR=TXT:MonitorRecord
WAIT SECONDS=5
FRAME F=2
TAG POS=1 TYPE=A ATTR=ID:ddlDC_Arrow
TAG POS=1 TYPE=LI ATTR=TXT:DC1
WAIT SECONDS=10
TAG POS=1 TYPE=A ATTR=ID:ddlCar_Arrow
TAG POS=1 TYPE=LI ATTR=TXT:{{!COL1}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:form1 ATTR=ID:date1 CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:form1 ATTR=ID:btnQuery
WAIT SECONDS=60
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:form1 ATTR=ID:Cexcel
WAIT SECONDS=60
TAB CLOSE
WAIT SECONDS=2
SET !ERRORIGNORE NO