Action()
{ //Correlation comment - Do not change!Original value='120696.679141353zcAiDDfptDDDDDDDDHcfApAVcz' Name ='CorrelationParameter_1' web_reg_save_param_ex( //---添加关联,关联需放在需关联的代码前面 "ParamName=CorrelationParameter_1", "LB=userSession value=", "RB=>\n<table border", SEARCH_FILTERS, "Scope=All", "RequestUrl=*/nav.pl*", LAST); web_url("WebTours", "URL=http://localhost:1080/WebTours/", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", EXTRARES, "URL=../favicon.ico", ENDITEM, LAST); web_reg_find("Text=, to the Web Tours reservation pages", //--添加检查点,这里检查的是登录后的检查点,可通过tree- 快照里找到需检查点,右击添加关联,可计数,然后登录后 再通过计数值判断是否登录成功。检查点需放在需检查代码前 "SaveCount=Welcome_Count", "Search=Body", LAST); lr_start_transaction("login"); //--添加事务 web_submit_data("login.pl", "Action=http://localhost:1080/WebTours/login.pl", "Method=POST", "TargetFrame=body", "RecContentType=text/html", "Referer=http://localhost:1080/WebTours/nav.pl?in=home", "Snapshot=t2.inf", "Mode=HTML", ITEMDATA, "Name=userSession", "Value={CorrelationParameter_1}", ENDITEM, //--用关联的参数代替 "Name=username", "Value={username}", ENDITEM, //--参数化 "Name=password", "Value={password}", ENDITEM, "Name=JSFormSubmit", "Value=off", ENDITEM, "Name=login.x", "Value=0", ENDITEM, "Name=login.y", "Value=0", ENDITEM, LAST); lr_end_transaction("login", LR_AUTO); //----结束事务 // Check result if (atoi(lr_eval_string("{Welcome_Count}")) > 0){ //--判断检查点是否已检查到 lr_output_message("Log on successful."); } else{ lr_error_message("Log on failed"); return(0); } // 退出登录 web_url("SignOff Button", "URL=http://localhost:1080/WebTours/welcome.pl?signOff=1", "TargetFrame=body", "Resource=0", "RecContentType=text/html", "Referer=http://localhost:1080/WebTours/nav.pl?page=menu&in=home", "Snapshot=t3.inf", "Mode=HTML", LAST);return 0;}