LoadRunner中关联问题

最近在测试google docs云业务,在录制了创建新文档的操作后,需要进行关联,每个文档都有一个ID,那么关联的话首先要将服务器生成的这个ID取出来,然后把下面用到此ID的所有链接都进行参数化,这样回放的时候才会真正成功的完成创建文档的操作。

开始在进行录制时,得到的创建文档的url的脚本

web_url("create", 
		"URL=https://docs.google.com/document/create?folder=0ALZWwXWNwhrNUk9PVA", 
		"TargetFrame=", 
		"Resource=0", 
		"RecContentType=text/html", 
		"Referer=", 
		"Snapshot=t13.inf", 
		"Mode=HTML", 
		EXTRARES, 
		"Url=https://ssl.gstatic.com/docs/documents/share/images/icons-7.png", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=https://ssl.gstatic.com/docs/common/jfk_sprite51.png", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=https://ssl.gstatic.com/ui/v1/disclosure/small-grey-disclosure-arrow-down.png", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=../static/document/client/js/351856489-kix_main_i18n_kix_app__zh_cn.js", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=https://ssl.gstatic.com/ui/v1/disclosure/small-grey-disclosure-arrow-up-down.png", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=https://ssl.gstatic.com/docs/presentations/images/spinner.gif", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=https://ssl.gstatic.com/gb/js/sem_feed2a2e2d54cd5f40fb4b5f5244fff2.js", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=../static/document/client/js/3891289192-kix_main_i18n_kix_tertiary__zh_cn.js", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0 rdot.gif", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=https://ssl.gstatic.com/scribe/sprite10_ebc72dd28fd4d84d065aa6e7cc97b753.png", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=https://ssl.gstatic.com/gb/images/s_513818bc.png", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=https://ssl.gstatic.com/scribe/searching.gif", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=https://ssl.gstatic.com/s2/profiles/images/silhouette200.png", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=../c/u/0/data/contactstore?ac=true&ct=true&gp=false&hl=zh-CN&id=personal&max=-1&out=js&tok&type=4", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=https://ssl.gstatic.com/docs/doclist/images/loading.gif", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=https://ssl.gstatic.com/ui/v1/menu/checkmark.png", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=https://ssl.gstatic.com/ui/v1/dialog/close-x.png", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/trash/read?id=1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0&token=AC4w5VhQoO_oMq5VfQFa9lj71bPyB8SqqQ%3A1341973079000", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/peruserchrome?id=1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0&token=AC4w5VhQoO_oMq5VfQFa9lj71bPyB8SqqQ%3A1341973079000", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/test?id=1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0&sid=5e18234728b52326&VER=8&token=AC4w5VhQoO_oMq5VfQFa9lj71bPyB8SqqQ%3A1341973079000&lsq=-1&u=03974857385217060086&w=1&MODE=init&zx=s9kt8m7aa3sf&t=1", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/test?id=1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0&sid=5e18234728b52326&VER=8&token=AC4w5VhQoO_oMq5VfQFa9lj71bPyB8SqqQ%3A1341973079000&lsq=-1&u=03974857385217060086&w=1&MODE=init&zx=ia3fg2vn8o6k&t=1", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=https://gg.google.com/csi?v=3&s=kix&action=edit_new&it=appLoad.2561,cursorMove.5,typeChar.3,basicEdit.3&e=docs_warm,docs_offline_warm,docs_offline_maybe_optout&rls=null&rt=", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		"Url=d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/test?id=1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0&sid=5e18234728b52326&VER=8&token=AC4w5VhQoO_oMq5VfQFa9lj71bPyB8SqqQ%3A1341973079000&lsq=-1&u=03974857385217060086&w=1&MODE=init&zx=gxeipgxotgsq&t=1", "Referer=https://docs.google.com/document/d/1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0/edit", ENDITEM, 
		LAST);

 由脚步可以看出,服务器为此文档生成的ID为

1gVZW2KXuUK1uCui6S0-5Q9r-pDRHmca3aoU7IIRLhN0

那么我们就要把此ID进行参数化,首先在creat的url上写上

web_reg_save_param("responseText",
        "LB=d/",
        "RB=/edit",
        "Search=All",
        LAST);

注意左右边界。然后将下面所有出现的ID进行参数化。

但是,问题出现了。。。

回放的时候发现,服务器没有返回新的ID,即服务器端并没有真正创建新文档。

此时分析上面脚步发现,create的url里包含很多url请求,而在第一个请求后服务器生成了一个ID,但在下面的请求中就直接用到了此ID,而这些请求都包含在一个url中(即create的url),因此想到的方法就是首先把第一个请求和下面的请求分开,在第一个请求后用web_reg_save_param去获得ID,然后在后面要用的ID的请求中参数化。

因此改变了录制模式

Recording Options->Recording,选择HTML-based script后,点击advanced,Script type中选择第二个,下面的选项也选择第二个,即Record in separate steps and use concurrent groups.

接着再次录制,产生脚本

web_url("create", 
		"URL=https://docs.google.com/document/create?folder=0ALZWwXWNwhrNUk9PVA", 
		"TargetFrame=", 
		"Resource=0", 
		"RecContentType=text/html", 
		"Referer=", 
		"Snapshot=t38.inf", 
		"Mode=HTML", 
		LAST);

 回放时在Replay log中发现此create产生了四个请求,并且服务器端生成了新的ID。此时,在上面再加上上述web_reg_save_param函数,并将下面脚本中所有以前的ID进行参数化。再次回放,打开google docs,发现文档创建成功。

总结:出现错误时,借助日志和必要的函数如web_reg_save_param分析客户端和服务器的交互,服务器的响应等信息来分析错误原因,并不断的尝试,相信问题一定会解决。

猜你喜欢

转载自tangyuan1314.iteye.com/blog/1585120