(四)对(三)中录制的登录代码中web_url、web_submit_form、lr_think_time、lr_end_transaction进行详解

详细请看help–>Function Reference–>目录–>Web Vuser Functions(WEB)—>Web Vuser Functions:C Language(WEB)–>Action Function
一、web_url

 int web_url( const char *StepName, 
<List of Attributes>, 
[EXTRARES, <List of Resource Attributes>,] 
LAST ); 

实例

web_url("WebTours", 
        "URL=http://127.0.0.1:1080/WebTours/", 
        ---URL下面是所有属性列表
        "Resource=0", ---A value indicating whether the URL is a resource;0不是;1"RecContentType=text/html", ---content-Type用于之处实体内容的MIME类型,因为HTTP协议传输的数据有各种类型,因此用MIME来标识不同的数据类型,在lr中的用途是告诉服务器,传过来的数据是text/html类型的。
        "Referer=", ---The URL of the referring Web page(该字段常被网站管理员用来追踪网站的访问者如何进入网站的,用于防盗链)
        "Snapshot=t1.inf", 
        "Mode=HTML", 
        EXTRARES, ---一个界定参数,指示下一个参数将是资源属性的列表(资源列表包括:URL、referer、ENDITEM)
        "Url=http://www.bing.com/favicon.ico", "Referer=", ENDITEM, ---A marker that indicates the end of each resource in the list
        LAST---A marker that indicates the end of the argument list.  
        );

二、web_submit_form

int web_submit_form( const char *StepName, 
<List of Attributes>, 
<List of Hidden Fields>, 
ITEMDATA, 
<List of Data Fields>, 
[ EXTRARES, <List of Resource Attributes>,] 
LAST ); 

实例:

web_submit_form("login.pl", 
---下面就是属性类别和隐藏字段列表
        "Snapshot=t2.inf", 
        ITEMDATA, ---A marker that separates between the attributes and the data of the form.下面为数据字段列表
        "Name=username", "Value=jojo", ENDITEM, 
        "Name=password", "Value=bean", ENDITEM, 
        "Name=login.x", "Value=57", ENDITEM, 
        "Name=login.y", "Value=22", ENDITEM, 
        LAST);

三、lr_think_time
lr函数在Help—>Function Reference–>目录–>Utility Function and C Language Reference—>Utility Functions:C Language(LR)—>Run-Time Functions中

void lr_think_time( double thinkTime); //该函数的作用是模拟真实用户在不同操作之间的停留时间
/*allows you to pause test execution during a run. 
This is especially useful in simulating think time, 
the time a real user pauses to think between actions.
*/

对思考时间进行设置:主要是当回放脚本时的思考时间进行设置
①可以在生成的脚本中对该时间进行修改。
②Edit Runtime Setting–>Think Time中进行修改
- Ignore think time:Instruct the Vuser to disable the think time
- Replay think time
–As recorded:Use think time that was recorded during the session
–Multiply recoreded think time by:按照录制时获取值的倍数回放脚本
–Use random percentage of recorded think time:以录制的时间在一定范围的随机值作为思考时间。(最常用的)
③这个时间的设置,一般在controller中进行设置(以同样的步骤),目的是模拟真实用户的操作。
在VuG中,是录制、调试脚本,是个单用户的操作,一般选择Ignore think time
希望执行越快越好

四、lr_end_transaction

int lr_end_transaction( const char *transaction_name, int status ) ; 
//status:事务结束状态
  • 之前已经知道VuG会监控网络中来往的数据包,脚本中的是客户端发往服务器的包,要查看来往的包,要看”Generation Log”
  • 若要查看脚本中每行的执行情况,则要看”Replay Log”双击这里的某行,则会对应脚本蓝色显示。
    比如
Action.c(20): Notify: Transaction "lookFlight" ended with "Pass" status (Duration: 0.5037 Wasted Time: 0.0049).
Ending action Action.

就对应代码:lr_end_transaction("lookFlight",LR_AUTO);

posted @ 2018-07-06 20:31  测试开发分享站  阅读(103)  评论(0编辑  收藏  举报