samedi 4 avril 2015

iMacros and Javascript Loop If Statement

This macro keeps giving me issues. I've searched and searched, but no luck. Once it tries to go to "finish01", it errors out.



var login01;
login01 ="CODE:";
login01 +="SET !ERRORIGNORE YES "+"\n";
login01 +="SET !EXTRACT_TEST_POPUP NO "+"\n";
login01 +="SET !REPLAYSPEED FAST "+"\n";
login01 +="SET !TIMEOUT 15 "+"\n";
login01 +="SET !EXTRACT NULL "+"\n";
login01 +="SET !DATASOURCE accounts20141121-2716--IP_set_2--fbr.csv "+"\n";
login01 +="SET !DATASOURCE_COLUMNS 2 "+"\n";
login01 +="SET !DATASOURCE_LINE {{i}} "+"\n";
login01 +="CLEAR "+"\n";
login01 +="TAB T=1 "+"\n";
login01 +="URL GOTO=http://ift.tt/1GdO5pj "+"\n";
login01 +="URL GOTO=http://ift.tt/PMWBDO "+"\n";
login01 +="URL GOTO=http://ift.tt/1bZ4RUk "+"\n";
login01 +="WAIT SECONDS=1 "+"\n";
login01 +="TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:http://ift.tt/1yMIQ85 ATTR=ID:login_user_login CONTENT={{!COL1}} "+"\n";
login01 +="SET !ENCRYPTION NO "+"\n";
login01 +="TAG POS=1 TYPE=INPUT:PASSWORD FORM=ACTION:http://ift.tt/1yMIQ85 ATTR=ID:password CONTENT={{!COL2}} "+"\n";
login01 +="WAIT SECONDS=1 "+"\n";
login01 +="TAG POS=1 TYPE=BUTTON FORM=ACTION:http://ift.tt/1yMIQ85 ATTR=TXT:Log<SP>In "+"\n";
login01 +="WAIT SECONDS=1 "+"\n";
login01 +="TAG POS=1 TYPE=BUTTON FORM=ACTION:http://ift.tt/1yMIQ87 ATTR=TXT:Send<SP>Email "+"\n";
login01 +="WAIT SECONDS=5 "+"\n";


var loginwait01;
loginwait01 ="CODE:";
loginwait01 +="SET !EXTRACT NULL "+"\n";
//loginwait01 +="TAG POS=1 TYPE=DIV ATTR=ID:login_error_message EXTRACT=TXT "+"\n";
loginwait01 +="TAG POS=1 TYPE=HTML ATTR=TXT:* EXTRACT=TXT "+"\n";


var loginagain01;
loginagain01 ="CODE:";
loginagain01 +="SET !ERRORIGNORE YES "+"\n";
loginagain01 +="SET !EXTRACT_TEST_POPUP NO "+"\n";
loginagain01 +="SET !REPLAYSPEED FAST "+"\n";
loginagain01 +="SET !TIMEOUT 15 "+"\n";
loginagain01 +="SET !EXTRACT NULL "+"\n";
loginagain01 +="SET !DATASOURCE accounts20141121-2716--IP_set_2--fbr.csv "+"\n";
loginagain01 +="SET !DATASOURCE_COLUMNS 2 "+"\n";
loginagain01 +="SET !DATASOURCE_LINE {{i}} "+"\n";
loginagain01 +="WAIT SECONDS=300 "+"\n";
loginagain01 +="URL GOTO=http://ift.tt/1bZ4RUk "+"\n";
loginagain01 +="WAIT SECONDS=1 "+"\n";
loginagain01 +="TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:http://ift.tt/1yMIQ85 ATTR=ID:login_user_login CONTENT={{!COL1}} "+"\n";
loginagain01 +="SET !ENCRYPTION NO "+"\n";
loginagain01 +="TAG POS=1 TYPE=INPUT:PASSWORD FORM=ACTION:http://ift.tt/1yMIQ85 ATTR=ID:password CONTENT={{!COL2}} "+"\n";
loginagain01 +="WAIT SECONDS=1 "+"\n";
loginagain01 +="TAG POS=1 TYPE=BUTTON FORM=ACTION:http://ift.tt/1yMIQ85 ATTR=TXT:Log<SP>In "+"\n";
loginagain01 +="WAIT SECONDS=1 "+"\n";
loginagain01 +="TAG POS=1 TYPE=BUTTON FORM=ACTION:http://ift.tt/1yMIQ87 ATTR=TXT:Send<SP>Email "+"\n";
loginagain01 +="WAIT SECONDS=5 "+"\n";


var finish01;
finish01 ="CODE:";
finish01 +="SET !ERRORIGNORE YES "+"\n";
finish01 +="SET !EXTRACT_TEST_POPUP NO "+"\n";
finish01 +="SET !REPLAYSPEED FAST "+"\n";
finish01 +="SET !TIMEOUT 15 "+"\n";
finish01 +="SET !EXTRACT NULL "+"\n";
finish01 +="SET !DATASOURCE accounts20141121-2716--IP_set_2--fbr.csv "+"\n";
finish01 +="SET !DATASOURCE_COLUMNS 2 "+"\n";
finish01 +="SET !DATASOURCE_LINE {{i}} "+"\n";
finish01 +="TAB OPEN "+"\n";
finish01 +="TAB T=2 "+"\n";
finish01 +="URL GOTO=http://quickmail.com "+"\n";
finish01 +="TAG POS=1 TYPE=INPUT:TEXT FORM=ID:mailboxform ATTR=NAME:box CONTENT={{!COL1}} "+"\n";
finish01 +="WAIT SECONDS=1 "+"\n";
finish01 +="TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:mailboxform ATTR=* "+"\n";
finish01 +="WAIT SECONDS=1 "+"\n";
finish01 +="TAG POS=1 TYPE=A ATTR=TXT:Your<SP>Example<SP>password "+"\n";
finish01 +="WAIT SECONDS=3 "+"\n";
finish01 +="FRAME F=1 "+"\n";
finish01 +="TAG POS=1 TYPE=A ATTR=STYLE:*background-color*color*line-height*40px*width*200px* EXTRACT=HREF "+"\n";
finish01 +="TAB OPEN "+"\n";
finish01 +="TAB T=3 "+"\n";
finish01 +="URL GOTO={{!EXTRACT}} "+"\n";
finish01 +="WAIT SECONDS=1 "+"\n";
finish01 +="TAG POS=1 TYPE=INPUT:PASSWORD FORM=ACTION:/user/reset_password_form ATTR=ID:password CONTENT=NEWPW01 "+"\n";
finish01 +="TAG POS=1 TYPE=INPUT:PASSWORD FORM=ACTION:/user/reset_password_form ATTR=ID:password_confirmation CONTENT=NEWPW01 "+"\n";
finish01 +="TAG POS=1 TYPE=BUTTON FORM=ACTION:/user/reset_password_form ATTR=TXT:Set<SP>Password "+"\n";
finish01 +="WAIT SECONDS=1 "+"\n";
finish01 +="TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:http://ift.tt/1yMIQ85 ATTR=ID:login_user_login CONTENT={{!COL1}} "+"\n";
finish01 +="TAG POS=1 TYPE=INPUT:PASSWORD FORM=ACTION:http://ift.tt/1yMIQ85 ATTR=ID:password CONTENT=NEWPW01 "+"\n";
finish01 +="TAG POS=1 TYPE=BUTTON FORM=ACTION:http://ift.tt/1yMIQ85 ATTR=TXT:Log<SP>In "+"\n";
finish01 +="WAIT SECONDS=1 "+"\n";
finish01 +="URL GOTO=http://ift.tt/1yMIRsP "+"\n";
finish01 +="WAIT SECONDS=1 "+"\n";
finish01 +="TAG POS=1 TYPE=IMG ATTR=SRC:http://ift.tt/1yMIRsR "+"\n";
finish01 +="WAIT SECONDS=1 "+"\n";
finish01 +="TAG POS=1 TYPE=BUTTON FORM=ACTION:/api-auth/allow ATTR=TXT:Authorize "+"\n";
finish01 +="WAIT SECONDS=1 "+"\n";
finish01 +="TAG POS=1 TYPE=H1 ATTR=TXT:* EXTRACT=TXT "+"\n";
finish01 +="SAVEAS TYPE=HTM FOLDER=c:\reports FILE=oauth_{{!LOOP}}__{{!COL1}}.htm "+"\n";
finish01 +="TAB CLOSEALLOTHERS "+"\n";
finish01 +="WAIT SECONDS=1 "+"\n";



var n=55
for (i = 1; i < n; i++)
{
iimSet("i",i)
iimPlay(login01);
iimSet("i",i);
iimPlay(loginwait01);
var lastextract = iimGetLastExtract();
if(lastextract.search("failed attempts")!=-1)
{
iimSet("i",i);
iimPlay(loginagain01);
}
iimSet("i",i);
iimPlay(finish01);
}


I'm re-setting the datasource_line for each individual macro that uses it, and also re-setting the "i" variable in imacros before starting each macro. I'm not sure what's causing the error. I'm guessing if you try and run this macro in iMacros Firefox, you'll also get an error right after it passes the 'if statement' in the loop.


Thanks in advance for any help!!


Aucun commentaire:

Enregistrer un commentaire