标签:span 使用 路径 ast share 场景 wan 127.0.0.1 post
主要学习Web(HTTP/HTML)协议的两种录制方式,重点包括以下内容:
--脚本录制的基本原则
--HTML和URL based script介绍
--选择录制方式的原则
--HTML based script设置介绍
1、脚本录制的基本原则
(1)充分考虑脚本的执行效率。
性能测试脚本关注的是如何模拟用户的真实行为。因此,用于测试的脚本应该接近用户的真实操作。这就要求录制后的脚本在修改的过程中不要增加过多内容,尤其是不能降低其运行效率。例如尽量不要增加循环、检查等操作,除非这些操作是必须的。
"基于此:检查点的设置一定要合理"
(2)录制重要的用户业务
要录制常用的、使用频率较高的业务来进行测试,不要什么内容都录制。
(3)选择需要的进行录制
在Web性能测试中,如果有些操作对于用户所关注的事物没有什么影响,那么可以不进行录制。例如,一些查询事物中,选择查询条件页面的请求过程可以不予录制,但对于一些要传递查询参数的过程则必须录制。(即凡是与Server服务器端进行交互的必须录制)
(4)录制前对参数要进行正确的配置
2、HTML和URL based script介绍
(1)基本概要
HTML based script:可以为每个用户请求生成单独的函数。
URL based script:可以捕获所有作为用户操作的结果发送到服务器的HTTP请求,然后一条条记录下来。它甚至可以捕获非HTML的程序,比如小程序和非浏览器应用程序。
HTML这种录制方式录制出来的脚本直观,易于理解和维护。而URL生成的脚本看起来比较长比较多。
(2)选择配置路径
当然还可以在:Tools-->>Recording Options处进行选择设置。
(3)两种录制方式录制出的脚本比较。
录制场景:Web Tours网站的登陆和退出
使用HTML based script录制的脚本如下显示:
Action() { web_url("tk.gif", "URL=http://addons.g-fox.cn/tk.gif?when=run&r=0.9908384090193264", "TargetFrame=", "Resource=1", "RecContentType=image/gif", "Referer=", "Snapshot=t1.inf", LAST); web_url("qvod-hao123.gif", "URL=http://addons.g-fox.cn/qvod-hao123.gif?c=http%3A%2F%2F127.0.0.1%3A1080%2FWebTours%2F&r=0.3669484254643438", "TargetFrame=", "Resource=1", "RecContentType=image/gif", "Referer=", "Snapshot=t2.inf", LAST); web_add_cookie("uid=38oGGVZ+d3CIW0zdBBKNAg==; DOMAIN=i.g-fox.cn"); web_url("coba_official_v2.json", "URL=http://i.g-fox.cn/notification/coba_official_v2.json", "TargetFrame=", "Resource=1", "RecContentType=application/json", "Referer=", "Snapshot=t3.inf", LAST); web_url("adu.gif", "URL=http://adu.g-fox.cn/adu.gif?channelid=www.firefox.com.cn&fxversion=32.0.1&ceversion=&ver=2_2&pk=%7Bd3c72884-7347-4670-9212-879a13a350f6%7D&uk=%7B4f29b2c6-db66-4dcd-ac4a-e548e110fce4%7D&cehome=false&locale=zh-CN&moexts=cpmanager,cehomepage,share_all_cn,coba,quicklaunch,commonfix,wx-assistant&age=626&default=false&defaultHttp=false&flash=25.0.0.148&now=1503456605300", "TargetFrame=", "Resource=1", "RecContentType=image/gif", "Referer=", "Snapshot=t4.inf", LAST); web_url("adu-new.gif", "URL=http://adu.g-fox.cn/adu-new.gif?ver=2_2&now=1503456605301&channelid=www.firefox.com.cn&fxversion=32.0.1&ceversion=&locale=zh-CN&age=626&pk=%7Bd3c72884-7347-4670-9212-879a13a350f6%7D&uk=%7B4f29b2c6-db66-4dcd-ac4a-e548e110fce4%7D&ude=true&default=false&defaultHttp=false&cehome=false&flash=25.0.0.148&moexts=cpmanager:1.5.14,cehomepage:0.10.47.3,share_all_cn:0.22,coba:1.0.35,quicklaunch:1.1.8,commonfix:0.13,wx-assistant:1.1.5&fxa=true", "TargetFrame=", "Resource=1", "RecContentType=image/gif", "Referer=", "Snapshot=t5.inf", LAST); lr_think_time(6); web_url("WebTours", "URL=http://127.0.0.1:1080/WebTours/", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Mode=HTML", EXTRARES, "Url=http://addons.g-fox.cn/firstLocation.gif?p=false&a=false&e=false&bsp=1&r=0.9296673577517076", "Referer=", ENDITEM, LAST); web_url("header.html", "URL=http://127.0.0.1:1080/WebTours/header.html", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/", "Mode=HTML", LAST); web_url("getcontentnew", "URL=http://front.meimotuan.com/api/getcontentnew?callback=jQuery18302938407202506831_1503456614146&guid=ZZ2FA3B363A1982A803A50A149BA5FAE&_=1503456614159", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/", "Snapshot=t6.inf", "Mode=HTML", LAST); web_url("welcome.pl", "URL=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=true", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/", "Snapshot=t7.inf", "Mode=HTML", LAST); web_add_cookie("renren_tag_0526=isTag; DOMAIN=127.0.0.1"); lr_think_time(12); web_submit_data("login.pl", "Action=http://127.0.0.1:1080/WebTours/login.pl", "Method=POST", "TargetFrame=body", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home", "Snapshot=t8.inf", "Mode=HTML", ITEMDATA, "Name=userSession", "Value=121786.684082625zczttAcpfzcfDHfizptVfDHf", ENDITEM, "Name=username", "Value=wang", ENDITEM, "Name=password", "Value=wang123456", ENDITEM, "Name=login.x", "Value=32", ENDITEM, "Name=login.y", "Value=12", ENDITEM, "Name=JSFormSubmit", "Value=off", ENDITEM, LAST); web_url("SignOff Button", "URL=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=1", "TargetFrame=body", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t9.inf", "Mode=HTML", LAST); web_add_cookie("MSO=SID&1503456615; DOMAIN=127.0.0.1"); web_add_cookie("MTUserInfo=firstName&wa&address2&beijing&username&wang&hash&39&lastName&ng%0A&address1&hebei&creditCard&88996688&expDate&11%2F12%0A; DOMAIN=127.0.0.1"); web_url("welcome.pl_2", "URL=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=1", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home", "Snapshot=t10.inf", "Mode=HTML", LAST); return 0; }
使用URL based script录制的脚本如下显示:
Action() { web_url("tk.gif", "URL=http://addons.g-fox.cn/tk.gif?when=run&r=0.7604677810829451", "Resource=1", "RecContentType=image/gif", "Referer=", "Snapshot=t11.inf", LAST); lr_think_time(5); web_url("adu.gif", "URL=http://adu.g-fox.cn/adu.gif?channelid=www.firefox.com.cn&fxversion=32.0.1&ceversion=&ver=2_2&pk=%7Bd3c72884-7347-4670-9212-879a13a350f6%7D&uk=%7B4f29b2c6-db66-4dcd-ac4a-e548e110fce4%7D&cehome=false&locale=zh-CN&moexts=cpmanager,cehomepage,share_all_cn,coba,quicklaunch,commonfix,wx-assistant&age=626&default=false&defaultHttp=false&flash=25.0.0.148&now=1503456910813", "Resource=1", "RecContentType=image/gif", "Referer=", "Snapshot=t12.inf", LAST); web_add_cookie("renren_tag_0526=isTag; DOMAIN=127.0.0.1"); web_url("WebTours", "URL=http://127.0.0.1:1080/WebTours/", "Resource=0", "RecContentType=text/html", "Referer=", "Mode=HTTP", LAST); web_url("firstLocation.gif", "URL=http://addons.g-fox.cn/firstLocation.gif?p=false&a=false&e=false&bsp=1&r=0.9261678897929481", "Resource=1", "RecContentType=image/gif", "Referer=", "Snapshot=t13.inf", LAST); web_url("header.html", "URL=http://127.0.0.1:1080/WebTours/header.html", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/", "Mode=HTTP", LAST); web_url("welcome.pl", "URL=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=true", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/", "Snapshot=t14.inf", "Mode=HTTP", LAST); web_concurrent_start(NULL); web_url("home.html", "URL=http://127.0.0.1:1080/WebTours/home.html", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=true", "Mode=HTTP", LAST); web_url("nav.pl", "URL=http://127.0.0.1:1080/WebTours/nav.pl?in=home", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=true", "Snapshot=t15.inf", "Mode=HTTP", LAST); web_concurrent_end(NULL); lr_think_time(11); web_submit_data("login.pl", "Action=http://127.0.0.1:1080/WebTours/login.pl", "Method=POST", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home", "Snapshot=t16.inf", "Mode=HTTP", ITEMDATA, "Name=userSession", "Value=121786.708464966zczttADpiVzzzzzHDHfizptccQ", ENDITEM, "Name=username", "Value=wang", ENDITEM, "Name=password", "Value=wang123456", ENDITEM, "Name=login.x", "Value=53", ENDITEM, "Name=login.y", "Value=4", ENDITEM, "Name=JSFormSubmit", "Value=off", ENDITEM, LAST); web_concurrent_start(NULL); web_url("nav.pl_2", "URL=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/login.pl", "Snapshot=t17.inf", "Mode=HTTP", LAST); web_url("login.pl_2", "URL=http://127.0.0.1:1080/WebTours/login.pl?intro=true", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/login.pl", "Snapshot=t18.inf", "Mode=HTTP", LAST); web_concurrent_end(NULL); lr_think_time(5); web_url("SignOff Button", "URL=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=1", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t19.inf", "Mode=HTTP", LAST); web_add_cookie("MSO=SID&1503456916; DOMAIN=127.0.0.1"); web_add_cookie("MTUserInfo=firstName&wa&address2&beijing&username&wang&hash&39&lastName&ng%0A&address1&hebei&creditCard&88996688&expDate&11%2F12%0A; DOMAIN=127.0.0.1"); web_url("welcome.pl_2", "URL=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=1", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home", "Snapshot=t20.inf", "Mode=HTTP", LAST); web_concurrent_start(NULL); web_url("home.html_2", "URL=http://127.0.0.1:1080/WebTours/home.html", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=1", "Mode=HTTP", LAST); web_url("nav.pl_3", "URL=http://127.0.0.1:1080/WebTours/nav.pl?in=home", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=1", "Snapshot=t21.inf", "Mode=HTTP", LAST); web_concurrent_end(NULL); return 0; }
3、通过两种录制方式的比较,我们得出脚本录制的原则,如下:
[1]基于浏览器的应用程序推荐使用HTML-based Script。
不是基于浏览器的应用程序推荐使用URL-based Script。
[2]如果基于浏览器的应用程序中包含了JavaScript并且该脚本向服务器产生了请求,比如DataGrid的分页按钮等,也要使用URL方式录制。
[3]基于浏览器的应用程序中使用了HTTPS安全协议,使用URL方式进行录制。
[4]对于初学者来说,如果HTML录制方式不成功,可以换成URL方式录制。
4、HTML based script设置介绍
(1)用来描述用户行为的脚本。直接创建的URL(web-url)、表单提交(Web_submit_form)、链接(Web_link)、和图像(Web_image)等函数。
(2)仅包含明确的URL脚本。这些脚本中所有的链接、图像请求和URL操作都被录制为Web_url函数,而表单提交则被录制为Web_submit_data函数。
标签:span 使用 路径 ast share 场景 wan 127.0.0.1 post
原文地址:http://www.cnblogs.com/haibaowang/p/7416799.html