lvyaoyang11 发表于 2011-5-19 13:59:55

LoadRunner参数化问题

在LoadRunner中对一个系统的登录名和密码进行参数化

在不进行参数化的时候运行脚本可以正常登录系统

为什么对两者进行参数化之后再运行脚本就只执行输入登录名,不输入密码了,也登录不了系统了

到底怎么对登录名和密码进行参数化啊,忘高手帮帮我啊,小弟在这里先谢谢大家了!!!下边是我参数化之后的代码:红字的地方是参数化的地方


#include "web_api.h"


Action()
{
        web_url("salt",
                "URL=http://192.168.1.133:8080/salt",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=",
                "Snapshot=t1.inf",
                "Mode=HTML",
                EXTRARES,
                "Url=/salt/images/BJ.jpg", "Referer=http://192.168.1.133:8080/salt/login.jsp", ENDITEM,
                "Url=/salt/images/loginbtn.gif", "Referer=http://192.168.1.133:8080/salt/login.jsp", ENDITEM,
                LAST);

        lr_think_time( 19 );

        web_submit_form("webUserlogin",
                "Snapshot=t2.inf",
                ITEMDATA,
                "Name=username", "Value={username}", ENDITEM,
                "Name=password", "Value={password}", ENDITEM,
                "Name=rand", "Value=0692", ENDITEM,
                "Name=button", "Value=", ENDITEM,
                EXTRARES,
                "Url=js/themes/default/images/menu_sep.png", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/default/images/button_a_bg.gif", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/icons/edit_remove.png", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/icons/ok.png", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/icons/cancel.png", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/default/images/menu.gif", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/default/images/panel_title.png", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/default/images/layout_button_left.gif", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/default/images/tabs_leftarrow.png", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/default/images/tabs_rightarrow.png", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/default/images/panel_tool_collapse.gif", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/default/images/panel_tool_expand.gif", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/icons/pencil.png", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/default/images/datagrid_header_bg.gif", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/default/images/pagination_prev.gif", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/default/images/pagination_next.gif", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/default/images/button_span_bg.gif", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/default/images/pagination_first.gif", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/icons/filesave.png", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/default/images/tabs_active.png", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/default/images/panel_tools.gif", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/default/images/pagination_last.gif", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                "Url=js/themes/default/images/pagination_load.png", "Referer=http://192.168.1.133:8080/salt/menu.jsp", ENDITEM,
                LAST);

        web_custom_request("getNavigationMenu",
                "URL=http://192.168.1.133:8080/salt/getNavigationMenu",
                "Method=POST",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=http://192.168.1.133:8080/salt/menu.jsp",
                "Snapshot=t3.inf",
                "Mode=HTML",
                "EncType=",
                LAST);

        web_custom_request("getNoReadMessage",
                "URL=http://192.168.1.133:8080/salt/getNoReadMessage",
                "Method=POST",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=http://192.168.1.133:8080/salt/menu.jsp",
                "Snapshot=t4.inf",
                "Mode=HTML",
                "EncType=",
                LAST);

        web_url("getBoardTypes",
                "URL=http://192.168.1.133:8080/salt/getBoardTypes?_=1305776781108",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=http://192.168.1.133:8080/salt/menu.jsp",
                "Snapshot=t5.inf",
                "Mode=HTML",
                LAST);

        web_submit_data("viewGridPublicInfo",
                "Action=http://192.168.1.133:8080/salt/viewGridPublicInfo",
                "Method=POST",
                "RecContentType=text/html",
                "Referer=http://192.168.1.133:8080/salt/menu.jsp",
                "Snapshot=t6.inf",
                "Mode=HTML",
                ITEMDATA,
                "Name=name", "Value=公司论坛", ENDITEM,
                "Name=page", "Value=1", ENDITEM,
                "Name=rows", "Value=10", ENDITEM,
                LAST);

        web_url("loginOut",
                "URL=http://192.168.1.133:8080/salt/loginOut",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=http://192.168.1.133:8080/salt/menu.jsp",
                "Snapshot=t7.inf",
                "Mode=HTML",
                EXTRARES,
                "Url=images/loginbtn.gif", ENDITEM,
                "Url=images/BJ.jpg", ENDITEM,
                LAST);

        return 0;

lvyaoyang11 发表于 2011-5-19 14:03:05

谢谢大家了说给我参数化的步骤也行,在这里先谢过大家了

lvyaoyang11 发表于 2011-5-19 14:08:38

高手们看到后帮一下我这个新手吧

archonwang 发表于 2011-5-19 14:09:09

这个比较简答啊。
几种办法,自己选择
1. username和password一起参数化,那么password和username必须是同一行,或者或者same as username
2. username 参数化,password固化

lvyaoyang11 发表于 2011-5-19 14:14:14

1 什么意思啊能不能帮我修改一下那地方的代码啊
2 固化是什么意思啊
谢谢你了

patrick_1984 发表于 2011-5-19 14:20:05

1. 在脚本里输出一下.验证下输入值.

2. 看看有没有空格加到参数里了.

lvyaoyang11 发表于 2011-5-19 14:28:56

6楼没有空格啊
页: [1]
查看完整版本: LoadRunner参数化问题