51Testing软件测试论坛

标题: How to put parameter into variable using LoadRunner ? [打印本页]

作者: dq_0413    时间: 2009-11-25 21:08
标题: How to put parameter into variable using LoadRunner ?
How to put parameter into variable using LoadRunner ?

--------THE DEMO BELOW--------

char sysbody[500];
   
vuser_init()
{
strcpy(sysbody,"Body=Usid=");
strcat(sysbody,lr_eval_string("{username}"));
strcat(sysbody,"&sgType=0&BetTime=2009%2D10%2D1%2010%3A27%3A04%20GMT%2B0700&LineNumber=7&GameType=12&BetMoney=0%2E01");

}
vuser_action()
{
  web_custom_request("jungleGameBet.jsp",
  "URL=http://www.168gdc.com/Laohuji/games/jungleGameBet.jsp",
  "Method=POST",
  "Resource=0",
  "RecContentType=text/html",
  "Referer=http://www.168gdc.com/Laohuji/games/slot_jungle.swf",
  "Snapshot=t40.inf",
  "Mode=HTML",
  sysbody,
  LAST);

}


-----SYNTAX & NOTE-----

1. To define an array with specific length and kind of Char. If need, setting the global variable
char sysuser[50];
2. Using the  C language function
Strcpy
Copies one string to another.
char *strcpy ( char *dest, const char *source );
dest
The destination string into which source is copied.
source
The string that is copied.


strcpy copies one string to another.
--------------------------------------------
Strcat
Concatenates two strings.
char *strcat ( char *to, const char *from );
to
The string at the end of which the from string is concatenated.
from
The string concatenated to the end of the to string.


strcat concatenates two strings.
3. Loadrunner system function
web_custom_request
Allows you to create a custom HTTP request with any method supported by HTTP.
int web_custom_request (const char *RequestName, <List of Attributes>,
[EXTRARES, <List of Resource Attributes>,] LAST );



----EXCERPT----

http://www.cnblogs.com/guanhe/archive/2006/09/04/494223.html

[ 本帖最后由 dq_0413 于 2009-11-25 21:50 编辑 ]




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2