LR - Script - Choose Val in Popup choice:-
choose_val(char* buf, char* LB, char* RB, char* val)
{
int i, idx, lg_lb;
char* p;
char* pe;
char* tab[500];
p = buf;
i=0;
lg_lb = strlen(LB);
while( i<500 && (p=(char*)strstr(p, LB)) != NULL ){
p += lg_lb;
tab[i] = p;
i++;
}
if( i > 0 ){
idx = (rand() % i);
p = tab[idx];
pe = (char*) strstr(p, RB);
// lr_error_message("i=%d idx=%d", i, idx);
if( pe != NULL ){
strncpy(val, p, pe-p);
val[pe-p] = '\0';
return 1;
}else{
return 0;
}
}
else{
return 0;
}
}
{
int i, idx, lg_lb;
char* p;
char* pe;
char* tab[500];
p = buf;
i=0;
lg_lb = strlen(LB);
while( i<500 && (p=(char*)strstr(p, LB)) != NULL ){
p += lg_lb;
tab[i] = p;
i++;
}
if( i > 0 ){
idx = (rand() % i);
p = tab[idx];
pe = (char*) strstr(p, RB);
// lr_error_message("i=%d idx=%d", i, idx);
if( pe != NULL ){
strncpy(val, p, pe-p);
val[pe-p] = '\0';
return 1;
}else{
return 0;
}
}
else{
return 0;
}
}
===============================================================
Exemple d'utilisation
web_reg_save_param( "applicants", "Notfound=warning", "LB/ic=<select name=\"cboApplicant\"", "RB/ic=</select>", "Ord=1", "Search=body", LAST );
web_reg_save_param( "VIEWSTATE_1", "LB=__VIEWSTATE\" value=\"", "RB=\"", "Ord=1", "Search=Body", "RelFrameId=1", LAST );
web_url("order_search.aspx",
"URL={url_ecom}/OrderStatus/order_search.aspx",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer={url_ecom}/Navigation/NavigMenu.htm",
"Snapshot=t6.inf",
"Mode=HTML",
LAST);
if( checkerr("Ebuy_OrdersManage") ) return rs;
lr_end_transaction("Ebuy_OrdersManage", LR_AUTO);
rc_appli=choose_val(lr_eval_string("{applicants}"), "value=\"","\"",applicant);
if( rc_appli ){
lr_save_string(applicant,"applicant");
web_reg_save_param( "VIEWSTATE_1", "LB=__VIEWSTATE\" value=\"", "RB=\"", "Ord=1", "Search=Body", "RelFrameId=1", LAST );
web_url("order_search.aspx",
"URL={url_ecom}/OrderStatus/order_search.aspx",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer={url_ecom}/Navigation/NavigMenu.htm",
"Snapshot=t6.inf",
"Mode=HTML",
LAST);
if( checkerr("Ebuy_OrdersManage") ) return rs;
lr_end_transaction("Ebuy_OrdersManage", LR_AUTO);
rc_appli=choose_val(lr_eval_string("{applicants}"), "value=\"","\"",applicant);
if( rc_appli ){
lr_save_string(applicant,"applicant");
...
}
No comments:
Post a Comment