51Testing软件测试论坛
标题:
loadrunner中写POP3脚本
[打印本页]
作者:
junior777
时间:
2015-7-1 17:35
标题:
loadrunner中写POP3脚本
Action()
{
long nums=0;//邮件数量
pop33 = 0;
//lr_think_time(1);
//登录POP3服务器
lr_start_transaction("POP3服务器登录");
pop3_logon_ex(&pop33, "Pop3Logon", //邮箱用户名与密码参数化
"URL={URL}:{password}@{type}",
LAST);
lr_end_transaction("POP3服务器登录",LR_AUTO);
lr_output_message("*****************%s %s %s",lr_eval_string("{URL}"),lr_eval_string("{password}"),lr_eval_string("{type}"));
lr_start_transaction("POP3邮件收取");
pop3_command_ex(&pop33, "Pop3Command", "Command=STAT", LAST);
nums=pop3_list_ex(&pop33,"Pop3List",LAST);
//列出POP3服务器上所有的邮件数量
lr_log_message ("**********There are %d message************.\r\n\r\n",nums); //显示收取的邮件数量
if(nums>0){//判断是否有未查收的邮件
//lr_save_int(nums,"numbs");
//pop3_retrieve_ex(&pop33,"Pop3Retrieve","RetrieveList=ALL", "DeleteMail=yes", LAST ); //接收全部邮件,删除
pop3_retrieve_ex(&pop33,"Pop3Retrieve","RetrieveList={num}", "DeleteMail=no", LAST ); //接收全部邮件,删除
//pop3_retrieve_ex(&pop33,"Pop3Retrieve","RetrieveList=1:{numbs}", "DeleteMail=no", LAST ); //接收全部邮件,删除
//lr_output_message("################%s",lr_eval_string("All"));
}
/*
else {
lr_end_transaction("POP3邮件收取",LR_AUTO);
return 0;//退出
}*/
/*
else if (nums>0) {
pop3_retrieve_ex(&pop33,"Pop3Retrieve","RetrieveList=ALL", "DeleteMail=no", LAST );
}
*/
lr_end_transaction("POP3邮件收取",LR_AUTO);
/*
if(nums>0){
lr_start_transaction("邮件删除");
//pop3_delete_ex(&pop33, "POP3", "DeleteList=1:{numbs}", LAST );
pop3_delete_ex(&pop33, "POP3", "DeleteList=1", LAST );
lr_end_transaction("邮件删除",LR_AUTO);
}
*/
pop3_logoff_ex(&pop33);
pop3_free_ex(&pop33);
return 0;
}
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2