Action()
{
//1、设置服务器的IP地址
//lr_save_string("192.168.1.12:8080", "ip");
lr_save_string("192.168.1.13:8080","ip");
//2、访问登录首页面
web_url("当当网",
"URL=http://{ip}/project",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
LAST);
//停顿2秒
lr_think_time(2);
//3、转到登录页面
web_url("登录页面",
"URL=http://{ip}/project/user/tologinAction",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://{ip}/project/",
"Snapshot=t2.inf",
"Mode=HTML",
LAST);
//停顿2秒
lr_think_time(2);
lr_start_transaction("提交登录信息");
//4、提交登录信息
web_submit_data("提交登录",
"Action=http://{ip}/project/user/login",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
"Referer=http://{ip}/project/user/tologinAction",
"Snapshot=t3.inf",
"Mode=HTML",
"EncodeAtSign=YES",
ITEMDATA,
"Name=user.email", "Value={userName}@project.com", ENDITEM,
"Name=user.password", "Value=123123", ENDITEM,
"Name=uri", "Value=", ENDITEM,
LAST);
lr_end_transaction("提交登录信息", LR_AUTO);
//停顿2秒
lr_think_time(2);
lr_start_transaction("浏览要购买的书籍");
//5、浏览要购买的书籍
web_url("书名:",
"URL=http://{ip}/project/main/book_view?id={bookId}",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://{ip}/project/main/mainAction",
"Snapshot=t4.inf",
"Mode=HTML",
LAST);
lr_end_transaction("浏览要购买的书籍", LR_AUTO);
//停顿2秒
lr_think_time(2);
lr_start_transaction("进入书籍详情信息");
//6、进入书籍详情信息
web_url("书籍详情",
"URL=http://{ip}/project/cart/cartBuy?id={bookId}",
"TargetFrame=",
"Resource=0",
"RecContentType=application/json",
"Referer=http://{ip}/project/main/book_view?id={bookId}",
"Snapshot=t5.inf",
"Mode=HTML",
LAST);
lr_end_transaction("进入书籍详情信息", LR_AUTO);
//停顿2秒
lr_think_time(2);
lr_start_transaction("查看购物车信息");
//7、查看购物车信息
web_url("购物车信息",
"URL=http://{ip}/project/cart/cart",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://{ip}/project/main/book_view?id={bookId}",
"Snapshot=t6.inf",
"Mode=HTML",
LAST);
lr_end_transaction("查看购物车信息", LR_AUTO);
//停顿2秒
lr_think_time(2);
lr_start_transaction("结算");
//8、结算
web_url("结算",
"URL=http://{ip}/project/order/confirm",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://{ip}/project/cart/cart",
"Snapshot=t7.inf",
"Mode=HTML",
LAST);
lr_end_transaction("结算", LR_AUTO);
//9-1、设置html支持的字符长度为1024
web_set_max_html_param_len("1024");
//9-2、设置关联,获取令牌的名字
web_reg_save_param("tokenName",
"LB=name="struts.token.name" value="",
"RB=" />",
LAST);
//9-3、设置关联,获取令牌的值
web_reg_save_param("token",
"LB=name="struts.token" value="",
"RB=" />",
LAST);
//9-4、设置关联,获取地址编号
web_reg_save_param("addressId",
"LB=id="addressId" value="",
"RB="/>",
LAST);
//停顿2秒
lr_think_time(2);
lr_start_transaction("选择收货地址");
//10、选择收货地址
web_url("选择收货地址",
"URL=http://{ip}/project/order/addressForm",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://{ip}/project/order/confirm",
"Snapshot=t8.inf",
"Mode=HTML",
LAST);
lr_end_transaction("选择收货地址", LR_AUTO);
//停顿2秒
lr_think_time(2);
lr_start_transaction("确定收货地址");
//11、确定收货地址
web_custom_request("确定收货地址",
"URL=http://{ip}/project/order/address",
"Method=POST",
"TargetFrame=",
"Resource=0",
"RecContentType=application/json",
"Referer=http://{ip}/project/order/addressForm",
"Snapshot=t9.inf",
"Mode=HTML",
"EncType=",
LAST);
lr_end_transaction("确定收货地址", LR_AUTO);
//停顿2秒
lr_think_time(2);
lr_start_transaction("提交订单信息");
//12、提交订单信息
web_submit_data("提交订单",
"Action=http://{ip}/project/order/orderSubmit",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
"Referer=http://{ip}/project/order/addressForm",
"Snapshot=t10.inf",
"Mode=HTML",
ITEMDATA,
"Name=struts.token.name", "Value={tokenName}", ENDITEM,
"Name=struts.token", "Value={token}", ENDITEM,
"Name=addr.id", "Value={addressId}", ENDITEM,
"Name=addr.receive_name", "Value=书籍1", ENDITEM,
"Name=addr.full_address", "Value=书籍2", ENDITEM,
"Name=addr.postal_code", "Value=123123", ENDITEM,
"Name=addr.phone", "Value=", ENDITEM,
"Name=addr.mobile", "Value=13800138000", ENDITEM,
"Name=submit", "Value=下一步", ENDITEM,
LAST);
lr_end_transaction("提交订单信息", LR_AUTO);
return 0;
}