If you’re like me, you want things to be as random as possible, this means selecting just about everything from a CSV or database. If you want to select a random line from your datasource, just create as many columns you need and use this code.
URL GOTO=http://www.graphpad.com/quickcalcs/randomN1.cfm
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:CFForm_1 ATTR=ID:low CONTENT=1
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:CFForm_1 ATTR=ID:hi CONTENT=10
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:CFForm_1 ATTR=NAME:Random
TAG POS=18 TYPE=TD ATTR=TXT:* EXTRACT=TXT
'
SET !VAR1 {{!EXTRACT}}
'
CMDLINE !DATASOURCE datasource.csv
SET !DATASOURCE_COLUMNS 1
SET !DATASOURCE_LINE {{!VAR1}}
The last three lines are what choose the random line in your CSV. Line 2 sets the low range and line 3 sets the high range of your random choice, so if you have a datasource with 55 lines, set the following.
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:CFForm_1 ATTR=ID:hi CONTENT=10
Hope that helps you use iMacros in a better and more random way!
I wrote some code here it is:
Its a 42 line random.csv file with 1 column and thic script chooses random line with each loop or run.
SET !EXTRACT_TEST_POPUP NO
CMDLINE !DATASOURCE Random.csv
SET !DATASOURCE_COLUMNS 1
SET !VAR3 EVAL(“var randomNumber=Math.floor(Math.random()*41 +1); randomNumber;”)
SET !DATASOURCE_LINE {{!VAR3}}
TAG POS=1 TYPE=INPUT ATTR=NAME:original EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:add_cms ATTR=NAME:user CONTENT={{!VAR1}}{{!COL1}}
SET !VAR2 EVAL(“var randomNumber=Math.floor(Math.random()*8 + 4); randomNumber;”)
‘ waits 4 to 8 seconds
WAIT SECONDS={{!VAR2}}