LR九:下载接口的测试

1.web_url(--------------)

2.判断方法 

使用下面这个函数

web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);

判断body的大小一般,不是0就是下载成功(这个函数会把body+header+chunking=的值)合计在一起,不为0表示成功。

3.特别要注意 要定义这个一个字符串   int size;

 

 1 Action()
 2 {
 3     int size;
 4     
 5     lr_start_transaction("download");
 6 
 7     web_url("get", 
 8 
 9     "URL=http://localhost:8080/pinter/file/api/download?id=1", 
10 
11     LAST ); 
12 
13 
14     size = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE); 
15 
16     lr_output_message("file size:%d",size);
17 
18     if (size > 3) {
19         
20         lr_end_transaction("download", LR_PASS);
21 
22     }else{
23 
24         
25         lr_end_transaction("download", LR_FAIL);
26 
27     }
28 
29     return 0;
30 }

运行日志如下:(看27-29行)

 1 Virtual User Script started at : 2019-03-16 19:27:56
 2 Starting action vuser_init.
 3 Web Turbo Replay of LoadRunner 11.0.0 for WINXP; build 8859 (Aug 18 2010 20:14:31)      [MsgId: MMSG-27143]
 4 Run Mode: HTML      [MsgId: MMSG-26000]
 5 Run-Time Settings file: "C:\test_huzhenyu\Script\LS\download\\default.cfg"      [MsgId: MMSG-27141]
 6 Ending action vuser_init.
 7 Running Vuser...
 8 Starting iteration 1.
 9 Starting action Action.
10 Action.c(5): Notify: Transaction "download" started.
11 Action.c(7): t=660ms: 131-byte response headers for "http://localhost:8080/pinter/file/api/download?id=1" (RelFrameId=1, Internal ID=1)
12 Action.c(7):     HTTP/1.1 200 \r\n
13 Action.c(7):     Content-Disposition: attachment; filename=a.txt\r\n
14 Action.c(7):     Transfer-Encoding: chunked\r\n
15 Action.c(7):     Date: Sat, 16 Mar 2019 11:27:56 GMT\r\n
16 Action.c(7):     \r\n
17 Action.c(7): t=688ms: 3-byte chunked response overhead for "http://localhost:8080/pinter/file/api/download?id=1" (RelFrameId=1, Internal ID=1)
18 Action.c(7):     e\r\n
19 Action.c(7): t=692ms: 7-byte chunked response overhead for "http://localhost:8080/pinter/file/api/download?id=1" (RelFrameId=1, Internal ID=1)
20 Action.c(7):     \r\n
21 Action.c(7):     0\r\n
22 Action.c(7):     \r\n
23 Action.c(7): t=711ms: 14-byte chunked response body for "http://localhost:8080/pinter/file/api/download?id=1" (RelFrameId=1, Internal ID=1)
24 Action.c(7):     abcd\r\n
25 Action.c(7):     12345\r\n
26 Action.c(7):     z
27 Action.c(7): web_url("get") was successful, 14 body bytes, 131 header bytes, 10 chunking overhead bytes      [MsgId: MMSG-26385]
28 Action.c(14): web_get_int_property was successful      [MsgId: MMSG-26392]
29 Action.c(16): file size:155
30 Action.c(20): Notify: Transaction "download" ended with "Pass" status (Duration: 0.5631 Wasted Time: 0.4300).
31 Ending action Action.
32 Ending iteration 1.
33 Ending Vuser...
34 Starting action vuser_end.
35 Ending action vuser_end.
36 Vuser Terminated.
log

 

posted @ 2019-03-16 19:32  测试艺术家  阅读(376)  评论(0编辑  收藏  举报