ossy
ossy

Reputation: 1

Infinite Loop with Imacros

Below is part of my Imacros code, i want an infinite loop. It picks up inputs from a CSV file and i want it to loop through the list when it gets to the end of the list say 1000. It starts again from line 1 till it gets to line 1000 and continues on and on. Thanks.

enter code here
TAB T=1
TAB CLOSEALLOTHERS
SET !DATASOURCE ddd.csv
SET !DATASOURCE_LINE {{!LOOP}}
SET !LOOP 10
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
URL GOTO=http://moonbit.co.in
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:MainForm    ATTR=ID:BodyPlaceholder_PaymentAddressTextbox CONTENT={{!COL1}}              
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:MainForm ATTR=ID:BodyPlaceholder_SignInButton
WAIT SECONDS=15
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:MainForm ATTR=ID:SubmitButton
FILEDELETE NAME=C:\images\captcha5.jpg
ONDOWNLOAD FOLDER=C:\images\ FILE=captcha5.jpg WAIT=YES
 WAIT SECONDS=3

Upvotes: 0

Views: 2581

Answers (1)

Shugar
Shugar

Reputation: 5299

Try this:

...
SET !DATASOURCE ddd.csv
SET linesInFile 1000
SET !LOOP 1
...
SET innerLoop EVAL("var i = \"{{!LOOP}}\" % \"{{linesInFile}}\"; (i == 0) ? \"{{linesInFile}}\" : i;")
SET !DATASOURCE_LINE {{innerLoop}}
...
TAG ... CONTENT={{!COL1}}
...

You must indicate exact number of lines in your file (variable 'linesInFile'). And on iMacros set the max. value of !LOOP to a very big integer (e.g. 99999) in order to get an infinite loop.

Upvotes: 1

Related Questions