51Testing软件测试论坛
标题:
为什么我回放总是登录不成功呢?
[打印本页]
作者:
让测试飞起来
时间:
2013-5-29 16:51
标题:
为什么我回放总是登录不成功呢?
下面是代码 是公司的内网 Action()
{
web_add_cookie("pgv_pvi=764706816; DOMAIN=www.ejbuy.com");
web_add_cookie("ECS[visit_times]=1; DOMAIN=www.ejbuy.com");
web_add_cookie("CNZZDATA4872384=cnzz_eid%3D281188941-1369708333-http%253A%252F%252Fwww.ejbuy.com%26ntime%3D1369708333%26cnzz_a%3D1%26retime%3D1369708350721%26sin%3D%26ltime%3D1369708350721%26rtime%3D0; DOMAIN=www.ejbuy.com");
web_add_cookie("bdshare_firstime=1369708333033; DOMAIN=www.ejbuy.com");
web_add_cookie("frontend=9gv353bsu6b6jj3ed84au34en1; DOMAIN=www.ejbuy.com");
web_url("www.ejbuy.com",
"URL=http://www.ejbuy.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
EXTRARES,
"Url=/skin/frontend/first/default/images/index_bg.png", ENDITEM,
"Url=/skin/frontend/first/default/images/topbg.png", ENDITEM,
"Url=/skin/frontend/first/default/images/top_sc.png", ENDITEM,
"Url=/skin/frontend/first/default/images/menu_bg.png", ENDITEM,
"Url=/skin/frontend/first/default/images/menu_s.png", ENDITEM,
"Url=/skin/frontend/first/default/images/menu_tel.png", ENDITEM,
"Url=/skin/frontend/first/default/images/fruit-icon.png", ENDITEM,
"Url=/skin/frontend/first/default/images/help4.png", ENDITEM,
"Url=/skin/frontend/first/default/images/new_tui_tbg.png", ENDITEM,
"Url=/skin/frontend/first/default/images/new_tui_active.png", ENDITEM,
"Url=/skin/frontend/first/default/images/floor_bg.png", ENDITEM,
"Url=/skin/frontend/first/default/images/help1.png", ENDITEM,
"Url=/skin/frontend/first/default/images/help2.png", ENDITEM,
"Url=/skin/frontend/first/default/images/help3.png", ENDITEM,
LAST);
web_url("getItemsSummaryQty",
"URL=http://www.ejbuy.com/index.php/cn/checkout/cart/getItemsSummaryQty/?_=1369818070798",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.ejbuy.com/",
"Snapshot=t2.inf",
"Mode=HTML",
LAST);
web_url("getItemsTotop",
"URL=http://www.ejbuy.com/index.php/cn/checkout/cart/getItemsTotop/?_=1369818070765",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.ejbuy.com/",
"Snapshot=t3.inf",
"Mode=HTML",
LAST);
web_url("login",
"URL=http://www.ejbuy.com/index.php/cn/customer/account/login/",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.ejbuy.com/",
"Snapshot=t4.inf",
"Mode=HTML",
EXTRARES,
"Url=/skin/frontend/first/default/images/index_bg.png", ENDITEM,
"Url=/skin/frontend/first/default/images/top_sc.png", ENDITEM,
"Url=/skin/frontend/first/default/images/help3.png", ENDITEM,
"Url=/skin/frontend/first/default/images/topbg.png", ENDITEM,
"Url=/skin/frontend/first/default/images/help4.png", ENDITEM,
"Url=/skin/frontend/first/default/images/help2.png", ENDITEM,
"Url=/skin/frontend/first/default/images/help1.png", ENDITEM,
LAST);
lr_think_time(12);
web_submit_data("loginpost",
"Action=http://www.ejbuy.com/index.php/cn/customer/account/loginpost/",
"Method=POST",
"RecContentType=application/json",
"Referer=http://www.ejbuy.com/index.php/cn/customer/account/login/",
"Snapshot=t5.inf",
"Mode=HTML",
"EncodeAtSign=YES",
ITEMDATA,
"Name=email", "Value=1300115774@qq.com", ENDITEM,
"Name=password", "Value=8639304", ENDITEM,
LAST);
web_url("index",
"URL=http://www.ejbuy.com/index.php/cn/customer/account/index/",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.ejbuy.com/index.php/cn/customer/account/login/",
"Snapshot=t6.inf",
"Mode=HTML",
EXTRARES,
"Url=/skin/frontend/first/default/images/index_bg.png", ENDITEM,
"Url=/skin/frontend/first/default/images/topbg.png", ENDITEM,
"Url=/skin/frontend/first/default/images/top_sc.png", ENDITEM,
"Url=/skin/frontend/first/default/images/help3.png", ENDITEM,
"Url=/skin/frontend/first/default/images/help2.png", ENDITEM,
"Url=/skin/frontend/first/default/images/help1.png", ENDITEM,
"Url=/skin/frontend/first/default/images/help4.png", ENDITEM,
"Url=/skin/frontend/first/default/images/menu_s.png", ENDITEM,
"Url=/skin/frontend/first/default/images/menu_bg.png", ENDITEM,
"Url=/skin/frontend/first/default/images/menu_tel.png", ENDITEM,
LAST);
web_url("getItemsTotop_2",
"URL=http://www.ejbuy.com/index.php/cn/checkout/cart/getItemsTotop/?_=1369818089401",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.ejbuy.com/index.php/cn/customer/account/index/",
"Snapshot=t7.inf",
"Mode=HTML",
LAST);
web_url("getItemsSummaryQty_2",
"URL=http://www.ejbuy.com/index.php/cn/checkout/cart/getItemsSummaryQty/?_=1369818089403",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.ejbuy.com/index.php/cn/customer/account/index/",
"Snapshot=t8.inf",
"Mode=HTML",
LAST);
web_url("alipay.png",
"URL=http://www.ejbuy.com/index.php/cn/customer/account/index/skin/frontend/first/default/images/alipay.png",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.ejbuy.com/index.php/cn/customer/account/index/",
"Snapshot=t9.inf",
"Mode=HTML",
LAST);
web_url("marstercard.png",
"URL=http://www.ejbuy.com/index.php/cn/customer/account/index/skin/frontend/first/default/images/marstercard.png",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.ejbuy.com/index.php/cn/customer/account/index/",
"Snapshot=t10.inf",
"Mode=HTML",
LAST);
web_url("visa.png",
"URL=http://www.ejbuy.com/index.php/cn/customer/account/index/skin/frontend/first/default/images/visa.png",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.ejbuy.com/index.php/cn/customer/account/index/",
"Snapshot=t11.inf",
"Mode=HTML",
LAST);
web_url("99bill.png",
"URL=http://www.ejbuy.com/index.php/cn/customer/account/index/skin/frontend/first/default/images/99bill.png",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.ejbuy.com/index.php/cn/customer/account/index/",
"Snapshot=t12.inf",
"Mode=HTML",
LAST);
web_url("tenpay.png",
"URL=http://www.ejbuy.com/index.php/cn/customer/account/index/skin/frontend/first/default/images/tenpay.png",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.ejbuy.com/index.php/cn/customer/account/index/",
"Snapshot=t13.inf",
"Mode=HTML",
LAST);
web_link("登出",
"Text=登出",
"Snapshot=t14.inf",
EXTRARES,
"Url=/skin/frontend/first/default/images/index_bg.png", "Referer=http://www.ejbuy.com/index.php/cn/customer/account/login/", ENDITEM,
"Url=/skin/frontend/first/default/images/top_sc.png", "Referer=http://www.ejbuy.com/index.php/cn/customer/account/login/", ENDITEM,
"Url=/skin/frontend/first/default/images/help3.png", "Referer=http://www.ejbuy.com/index.php/cn/customer/account/login/", ENDITEM,
"Url=/skin/frontend/first/default/images/topbg.png", "Referer=http://www.ejbuy.com/index.php/cn/customer/account/login/", ENDITEM,
"Url=/skin/frontend/first/default/images/help4.png", "Referer=http://www.ejbuy.com/index.php/cn/customer/account/login/", ENDITEM,
"Url=/skin/frontend/first/default/images/help2.png", "Referer=http://www.ejbuy.com/index.php/cn/customer/account/login/", ENDITEM,
"Url=/skin/frontend/first/default/images/help1.png", "Referer=http://www.ejbuy.com/index.php/cn/customer/account/login/", ENDITEM,
LAST);
return 0;
}
登录 是不成功
用了自动关联也没有用
[attach]85316[/attach]
作者:
让测试飞起来
时间:
2013-5-29 17:24
用LR录制51网登录 自动关联 回放可以成功
为什么我上面的这个不可以呢?
作者:
让测试飞起来
时间:
2013-5-29 17:34
自动关联找不到要关联的
作者:
wangyueyong1
时间:
2013-6-3 09:12
lr录制51登陆能成功,你登陆51的验证码是怎么处理的
作者:
ljl0896
时间:
2013-6-16 23:25
我只实践过我们项目组的一个OA系统的性能测试。你的cookie部分貌似加密了(可能是变化的),而且链接中有“?_=1369818089403”,不知道是不是随机的日期组合。
如果服务器每次给你返回的数据都是不一样的,那就需要做关联(我一般都是手动关联)。以下是我模拟登录操作时做的cookie关联:
web_url("oa.oatest.gdb.com.cn", //在地址栏输入oa地址
"URL=http://oa.oatest.gdb.com.cn/",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
LAST);
/*------------------------关联获取下个请求服务器返回数据--------------------------------*/
web_reg_save_param("mSessionId",
"LB=ASP.NET_SessionId=", //用户每次访问都会在服务器生成一个会话ID作为区分,需要关联这个动态的信息。
"RB=;",
"Search=Headers",
LAST);
/*--------------------------------end-------------------------------------------------*/
web_url("Login.aspx", //用户未登录,先跳转到sso登录页面
"URL=http://sso.oatest.gdb.com.cn/Login.aspx?url=http%3a%2f%2foa.oatest.gdb.com.cn%2f",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t2.inf",
"Mode=HTML",
EXTRARES,
LAST);
web_set_max_html_param_len("36606");
/*------------------------关联获取下个请求服务器返回数据---------------------------------*/
web_reg_save_param("mPortal",
"LB=__Portal_Passport__=",//sso登录验证通过后返回的cookie,登录后的每次操作都要使用它作为凭据
"RB=;",
"Search=Headers",
LAST);
lr_output_message("验证是否关联成功打印出SessionID:%s",lr_eval_string("{mSessionId}"));
/*--------由于在请求时是在head里面加cookie,不能关联后直接在界面输入,所以用add_cookie-------*/
web_add_cookie("ASP.NET_SessionId={mSessionId};domain=sso.oatest.gdb.com.cn");
/*--------------------------------end-------------------------------------------------*/
lr_think_time(3);
lr_start_transaction("登录");
web_submit_data("Login.aspx_2", //输入用户名、密码,进行登录操作
"Action=http://sso.oatest.gdb.com.cn/Login.aspx?url=http%3a%2f%2foa.oatest.gdb.com.cn%2f",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
"Referer=http://sso.oatest.gdb.com.cn/Login.aspx?url=http%3a%2f%2foa.oatest.gdb.com.cn%2f",
"Snapshot=t3.inf",
"Mode=HTML",
ITEMDATA,
"Name=__EVENTTARGET", "Value=", ENDITEM,
"Name=__EVENTARGUMENT", "Value=", ENDITEM,
//用到服务器返回的第一个VIEWSTATE和EVENTVALIDATION,打开登录界面就有,而且所有用户的都相同。不需要关联。
"Name=__VIEWSTATE", "Value=/wEPDwUJMjQ3MTMwMTQ5D2QWAgIBD2QWBAIFDxBkEBUCBuWKnuWFrAbmn5zlj7AVAgN0b2EEdHByZBQrAwJnZ2RkAhEPDxYCHgRUZXh0ZGRkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYCBRNjaGtSZW1lbWJlclVzZXJOYW1lBQ5jaGtSZW1lbmJlclB3ZA==", ENDITEM,
"Name=__EVENTVALIDATION", "Value=/wEWCgKq5NaZCwKdhdqTCgK1qbSRCwKVku7+CgK4/L27DgLkz7mrBwKC3IeGDAKhrJ7LAwKw8pLgCgK+6b6zDA==", ENDITEM,
"Name=txtLoginID", "Value={user}", ENDITEM,
"Name=txtPassword", "Value=pass@word1", ENDITEM,
"Name=radAccountType", "Value=toa", ENDITEM,
"Name=btnLogin2", "Value=", ENDITEM,
EXTRARES,
LAST);
/*------------------------------关联----------------------------------------------------------------------*/
web_reg_save_param("mSessionId2",
"LB=ASP.NET_SessionId=", //服务器返回第二个ASP.NET_SessionId
"RB=;",
"Search=Headers",
LAST);
lr_output_message("验证是否关联成功打印出Portal_Passport:%s",lr_eval_string("{mPortal}"));
/*-------------------------------------------add_cookie-----------------------------------------------------------*/
web_add_cookie("__Portal_Passport__={mPortal};domain=10.2.49.40");//sso生成的数据
web_add_cookie("BS_SsoUserInfo={mUserInfo};domain=10.2.49.40");//sso生成的用户信息数据
web_add_cookie("ASP.NET_SessionId={mSessionId};domain=10.2.49.40");
/*----------------------------------------------end---------------------------------------------------------------*/
web_url("oa.oatest.gdb.com.cn_2", //成功登录后,跳转到oa网站
我是用httpwatch了解网站是怎样跳转、客户端要提交什么样的凭据给服务器、服务器是什么时候在哪里返回这些数据的、这些数据是否是变化的等等之后,再去模拟客户端跟服务器的交互过程的。这样才知道什么时候需要关联,关联之后写个lr_output_message,提示是否已经关联成功,这样才能知道登录操作过程是在哪里失败的。
初学的经验,不知道对你是否有帮助。
作者:
让测试飞起来
时间:
2013-6-17 15:32
回复
4#
wangyueyong1
晕 要验证码吗?
作者:
让测试飞起来
时间:
2013-6-17 15:32
回复
4#
wangyueyong1
晕 要验证码吗?
作者:
让测试飞起来
时间:
2013-6-17 15:32
回复
4#
wangyueyong1
晕 要验证码吗?
作者:
让测试飞起来
时间:
2013-6-17 15:32
回复
4#
wangyueyong1
晕 要验证码吗?
作者:
让测试飞起来
时间:
2013-6-17 15:32
回复
4#
wangyueyong1
晕 要验证码吗?
作者:
让测试飞起来
时间:
2013-6-17 15:52
回复
5#
ljl0896
上面的代码是在首页面录制的,回放登录没有成功
但是在结账(电商网站)时登录的话回放就可以成功。
这个代码
web_url("onepage",
"URL=http://www.ejbuy.com/index.php/cn/checkout/onepage/",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.ejbuy.com/index.php/cn/catalogsearch/result/?q=%E6%AC%A2%E8%BF%8E%E6%9D%A5%E5%88%B0%E6%98%93%E6%8D%B7%E5%95%86%E5%9F%8E%2C1300115774%40qq.com++++%E7%99%BB%E5%87%BA+%E6%88%91%E7%9A%84%E6%98%93%E6%8D%B7%E6%88%91%E7%9A%84%E8%AE%A2%E5%8D%95+%E6%88%91%E7%9A%84%E6%94%B6%E8%97%8F+%E6%94%B6%E8%97%8F%E6%9C%AC%E7%AB%99+++%E7%83%AD%E9%97%A8%E6%90%9C%E7%B4%A2%E8%AF%8D%3A+computer+00+%E4%B8%AD%E5%9B%BD%E9%A3%8E%E5%A5%B3%E7%AB%A5%E7%BA%AF%E6%A3%89%E5%9C%86+22+01+55+"
"%E6%90%9C%E7%B4%A2%E8%B4%AD%E7%89%A9%E8%BD%A6%28120%E4%BB%B6%29%E6%88%91%E7%9A%84%E8%B4%AD%E7%89%A9%E8%BD%A6Couch599.99x20",
"Snapshot=t34.inf",
"Mode=HTML",
LAST);
web_concurrent_start(NULL);
web_url("opc-ajax-loader.gif",
"URL=http://www.ejbuy.com/skin/frontend/first/default/images/opc-ajax-loader.gif",
"Resource=1",
"RecContentType=image/gif",
"Referer=http://www.ejbuy.com/index.php/cn/checkout/onepage/",
"Snapshot=t35.inf",
LAST);
web_url("top_sc.png_6",
"URL=http://www.ejbuy.com/skin/frontend/first/default/images/top_sc.png",
"Resource=1",
"Referer=http://www.ejbuy.com/index.php/cn/checkout/onepage/",
LAST);
web_url("topbg.png_6",
"URL=http://www.ejbuy.com/skin/frontend/first/default/images/topbg.png",
"Resource=1",
"Referer=http://www.ejbuy.com/index.php/cn/checkout/onepage/",
LAST);
web_url("index_bg.png_6",
"URL=http://www.ejbuy.com/skin/frontend/first/default/images/index_bg.png",
"Resource=1",
"Referer=http://www.ejbuy.com/index.php/cn/checkout/onepage/",
LAST);
web_url("ejbuy_bg03.png",
"URL=http://www.ejbuy.com/skin/frontend/first/default/images/ejbuy_bg03.png",
"Resource=1",
"RecContentType=image/png",
"Referer=http://www.ejbuy.com/index.php/cn/checkout/onepage/",
"Snapshot=t36.inf",
LAST);
web_url("cvv.gif",
"URL=http://www.ejbuy.com/skin/frontend/base/default/images/cvv.gif",
"Resource=1",
"RecContentType=image/gif",
"Referer=http://www.ejbuy.com/index.php/cn/checkout/onepage/",
"Snapshot=t37.inf",
LAST);
web_concurrent_end(NULL);
lr_think_time(12);
web_submit_form("loginPost",
"Snapshot=t38.inf",
ITEMDATA,
"Name=login[username]", "Value=1300115774@qq.com", ENDITEM,
"Name=login[password]", "Value=8639304", ENDITEM,
LAST);
web_concurrent_start(NULL);
web_url("cvv.gif_2",
"URL=http://www.ejbuy.com/skin/frontend/base/default/images/cvv.gif",
"Resource=1",
"Referer=http://www.ejbuy.com/index.php/cn/checkout/onepage/index/",
LAST);
web_url("opc-ajax-loader.gif_2",
"URL=http://www.ejbuy.com/skin/frontend/first/default/images/opc-ajax-loader.gif",
"Resource=1",
"Referer=http://www.ejbuy.com/index.php/cn/checkout/onepage/index/",
LAST);
web_url("ejbuy_bg03.png_2",
"URL=http://www.ejbuy.com/skin/frontend/first/default/images/ejbuy_bg03.png",
"Resource=1",
"Referer=http://www.ejbuy.com/index.php/cn/checkout/onepage/index/",
LAST);
web_url("index_bg.png_7",
"URL=http://www.ejbuy.com/skin/frontend/first/default/images/index_bg.png",
"Resource=1",
"Referer=http://www.ejbuy.com/index.php/cn/checkout/onepage/index/",
LAST);
web_url("top_sc.png_7",
"URL=http://www.ejbuy.com/skin/frontend/first/default/images/top_sc.png",
"Resource=1",
"Referer=http://www.ejbuy.com/index.php/cn/checkout/onepage/index/",
LAST);
web_url("topbg.png_7",
"URL=http://www.ejbuy.com/skin/frontend/first/default/images/topbg.png",
"Resource=1",
"Referer=http://www.ejbuy.com/index.php/cn/checkout/onepage/index/",
LAST);
web_concurrent_end(NULL);
作者:
jasonwong420281
时间:
2013-6-17 16:50
学习了
作者:
ljl0896
时间:
2013-6-17 23:46
回复
11#
让测试飞起来
貌似你用的是URL-based script 模式,不是 HTML-based script模式。我一般只用HTML-based script模式。因为前面那种会将客户端跟服务器的所有交互记录都录制下来,比如你记录里面图片资源交互过程。这个应该不能完全说“回放成功”了,可能回放成功的只是一部分资源的申请》返回过程。
建议你用httpwatch录制一下,看一下你这个登录登出操作过程中是怎样与服务器交互的。我的经验是:
1.了解它的页面是怎样跳转的,比如在地址栏输入“
http://www.51testing.com/
”,它跳转到了“
http://www.51testing.com/html/index.html
”,输入用户名密码之后点击【登录】,跳转到验证码页面……
2.完成一个登录登出操作全过程之后,可以忽略掉图片等资源的交互过程,录制两遍对比一下不同的地方,看一下我们跳转这些链接的过程中,客户端要提交给服务器的数据是不是一样的,比如session产生的cookie、用userid随机产生的加密链接等(如果是用户名、密码等这些,用的是参数化)。
3.如果每次服务器返回的数据都一样,可以直接add进去;如果每次都不一样,就要做关联(我一般手动关联,关联的地方就是找到服务器第一次返回这个数据的地方,关联起来)。然后在客户端需要用提交这个数据时add进去。
其实就是模拟客户端跟服务器交互的过程,如果不知道它在哪里失败了,就写一些message放在回放记录里面,就知道在哪里不通过了。(永远先找第一个错误,即使后面错了几万条记录,先看第一个记录为什么失败了。)
这是我学习的过程,希望对你有帮助。
作者:
linneiwei
时间:
2013-6-18 21:38
楼上说得对,录制两次对比下,最好可以录制与回放日志进行对比,这样就知道动态变化在什么地方,看那些需要关联,另外也可能是Cookie问题,最好能比较出来。
loadrunner比较这块没kylinPET工具直观,所以可以使用kylinPET工具测试下,它支持录制日志与回放日志比较,不同之处标识红色,一目了然知道录制与回放哪里不一样,这样可以快速定位出问题
作者:
lin39320028
时间:
2013-6-19 14:58
顶kylinPET,最近用了该工具,确实很方便。尤其是比较两次录制脚本自动关联,很大程度上提升脚本效率,而且回放能与录制日志比较定位脚本问题,确实不错。
作者:
让测试飞起来
时间:
2013-7-31 10:05
回复
4#
wangyueyong1
不用的吧!
作者:
让测试飞起来
时间:
2013-7-31 10:14
回复
15#
lin39320028
亲加我企鹅吧1
1300115774
作者:
地壳
时间:
2013-7-31 12:11
录制两次完全一样的脚本,手动关联吧!
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2