请问这个脚本该如何修改
新手请教:我要在我们防火墙上WEB操作建立多个地址对象,以下是我录制的建立5个地址对象的脚本,怎么把它修改成可以建立任意个地址对象的脚本。第一次用这个,改了半天没弄成。求助,谢谢!Action()
{
web_url("192.2.2.24:2000",
"URL=http://192.2.2.24:2000/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
EXTRARES,
"Url=/images/but_login.gif", "Referer=http://192.2.2.24:2000/login", ENDITEM,
LAST);
web_submit_form("login",
"Snapshot=t2.inf",
ITEMDATA,
"Name=username", "Value=admin", ENDITEM,
"Name=password", "Value=admin", ENDITEM,
"Name=Submit", "Value=", ENDITEM,
EXTRARES,
"Url=/images/bg_nav_menu_level1.gif", "Referer=http://192.2.2.24:2000/navigator", ENDITEM,
"Url=/images/bg_nav_menu_level2.gif", "Referer=http://192.2.2.24:2000/navigator", ENDITEM,
"Url=/images/bg_nav_menu_level1_over.gif", "Referer=http://192.2.2.24:2000/navigator", ENDITEM,
"Url=/images/bg_bar_blue.gif", "Referer=http://192.2.2.24:2000/system/status/status", ENDITEM,
"Url=/images/bg_button.gif", "Referer=http://192.2.2.24:2000/system/status/status", ENDITEM,
"Url=/images/bg_nav_menu_level1_open.gif", "Referer=http://192.2.2.24:2000/navigator", ENDITEM,
"Url=/images/bg_nav_menu_level2_over.gif", "Referer=http://192.2.2.24:2000/navigator", ENDITEM,
"Url=/images/bg_nav_menu_level2_open.gif", "Referer=http://192.2.2.24:2000/navigator", ENDITEM,
LAST);
web_url("button",
"URL=http://192.2.2.24:2000/button?button=address,addr_group&button_url=/firewall/address/address,/firewall/address/group",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.24:2000/home",
"Snapshot=t3.inf",
"Mode=HTML",
EXTRARES,
"Url=/images/but_lo.gif", "Referer=http://192.2.2.24:2000/button?button=address,addr_group&button_url=/firewall/address/address,/firewall/address/group", ENDITEM,
"Url=/images/but_rf.gif", "Referer=http://192.2.2.24:2000/button?button=address,addr_group&button_url=/firewall/address/address,/firewall/address/group", ENDITEM,
LAST);
web_url("address",
"URL=http://192.2.2.24:2000/firewall/address/address",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.24:2000/home",
"Snapshot=t4.inf",
"Mode=HTML",
EXTRARES,
"Url=/images/but_of.gif", "Referer=http://192.2.2.24:2000/button?button=address,addr_group&button_url=/firewall/address/address,/firewall/address/group", ENDITEM,
LAST);
web_url("dlg",
"URL=http://192.2.2.24:2000/firewall/address/dlg",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.24:2000/home",
"Snapshot=t5.inf",
"Mode=HTML",
LAST);
lr_think_time(11);
web_submit_form("dlg_2",
"Snapshot=t6.inf",
ITEMDATA,
"Name=addrname", "Value=1", ENDITEM,
"Name=addrtype", "Value=1", ENDITEM,
"Name=ipaddr", "Value=1.1.1.1", ENDITEM,
"Name=netmask", "Value=255.255.255.0", ENDITEM,
"Name=confirmbutton", "Value=È·¶¨", ENDITEM,
LAST);
web_url("msgdlg",
"URL=http://192.2.2.24:2000/common/common/msgdlg?list=/firewall/address/address&msg=%B2%D9%D7%F7%B3%C9%B9%A6%21",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.24:2000/home",
"Snapshot=t7.inf",
"Mode=HTML",
LAST);
web_url("address_2",
"URL=http://192.2.2.24:2000/firewall/address/address",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.24:2000/home",
"Snapshot=t8.inf",
"Mode=HTML",
LAST);
web_url("dlg_3",
"URL=http://192.2.2.24:2000/firewall/address/dlg",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.24:2000/home",
"Snapshot=t9.inf",
"Mode=HTML",
LAST);
lr_think_time(12);
web_submit_form("dlg_4",
"Snapshot=t10.inf",
ITEMDATA,
"Name=addrname", "Value=2", ENDITEM,
"Name=addrtype", "Value=1", ENDITEM,
"Name=ipaddr", "Value=1.1.1.2", ENDITEM,
"Name=netmask", "Value=255.255.255.0", ENDITEM,
"Name=confirmbutton", "Value=È·¶¨", ENDITEM,
LAST);
web_url("msgdlg_2",
"URL=http://192.2.2.24:2000/common/common/msgdlg?list=/firewall/address/address&msg=%B2%D9%D7%F7%B3%C9%B9%A6%21",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.24:2000/home",
"Snapshot=t11.inf",
"Mode=HTML",
LAST);
web_url("address_3",
"URL=http://192.2.2.24:2000/firewall/address/address",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.24:2000/home",
"Snapshot=t12.inf",
"Mode=HTML",
LAST);
web_url("dlg_5",
"URL=http://192.2.2.24:2000/firewall/address/dlg",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.24:2000/home",
"Snapshot=t13.inf",
"Mode=HTML",
LAST);
lr_think_time(9);
web_submit_form("dlg_6",
"Snapshot=t14.inf",
ITEMDATA,
"Name=addrname", "Value=3", ENDITEM,
"Name=addrtype", "Value=1", ENDITEM,
"Name=ipaddr", "Value=1.1.1.3", ENDITEM,
"Name=netmask", "Value=255.255.255.0", ENDITEM,
"Name=confirmbutton", "Value=È·¶¨", ENDITEM,
LAST);
web_url("msgdlg_3",
"URL=http://192.2.2.24:2000/common/common/msgdlg?list=/firewall/address/address&msg=%B2%D9%D7%F7%B3%C9%B9%A6%21",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.24:2000/home",
"Snapshot=t15.inf",
"Mode=HTML",
LAST);
web_url("address_4",
"URL=http://192.2.2.24:2000/firewall/address/address",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.24:2000/home",
"Snapshot=t16.inf",
"Mode=HTML",
LAST);
web_url("dlg_7",
"URL=http://192.2.2.24:2000/firewall/address/dlg",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.24:2000/home",
"Snapshot=t17.inf",
"Mode=HTML",
LAST);
lr_think_time(10);
web_submit_form("dlg_8",
"Snapshot=t18.inf",
ITEMDATA,
"Name=addrname", "Value=4", ENDITEM,
"Name=addrtype", "Value=1", ENDITEM,
"Name=ipaddr", "Value=1.1.1.4", ENDITEM,
"Name=netmask", "Value=255.255.255.0", ENDITEM,
"Name=confirmbutton", "Value=È·¶¨", ENDITEM,
LAST);
web_url("msgdlg_4",
"URL=http://192.2.2.24:2000/common/common/msgdlg?list=/firewall/address/address&msg=%B2%D9%D7%F7%B3%C9%B9%A6%21",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.24:2000/home",
"Snapshot=t19.inf",
"Mode=HTML",
LAST);
web_url("address_5",
"URL=http://192.2.2.24:2000/firewall/address/address",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.24:2000/home",
"Snapshot=t20.inf",
"Mode=HTML",
LAST);
web_url("dlg_9",
"URL=http://192.2.2.24:2000/firewall/address/dlg",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.24:2000/home",
"Snapshot=t21.inf",
"Mode=HTML",
LAST);
lr_think_time(9);
web_submit_form("dlg_10",
"Snapshot=t22.inf",
ITEMDATA,
"Name=addrname", "Value=5", ENDITEM,
"Name=addrtype", "Value=1", ENDITEM,
"Name=ipaddr", "Value=1.1.1.5", ENDITEM,
"Name=netmask", "Value=255.255.255.0", ENDITEM,
"Name=confirmbutton", "Value=È·¶¨", ENDITEM,
LAST);
web_url("msgdlg_5",
"URL=http://192.2.2.24:2000/common/common/msgdlg?list=/firewall/address/address&msg=%B2%D9%D7%F7%B3%C9%B9%A6%21",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.24:2000/home",
"Snapshot=t23.inf",
"Mode=HTML",
LAST);
web_url("address_6",
"URL=http://192.2.2.24:2000/firewall/address/address",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.24:2000/home",
"Snapshot=t24.inf",
"Mode=HTML",
EXTRARES,
"Url=/theme/images/twistie_expanded.gif", ENDITEM,
LAST);
return 0;
} 各位兄弟帮帮忙,帮看看,帮做个例子我学习学习啊 :L 写个注释先吧,这叫谁看得懂啊 我重新整理了下,以最简单的建立两个IP地址对象的为例:Action()
{
########################################################################
#登陆防火墙
##############################################
web_url("192.2.2.123:2000",
"URL=http://192.2.2.123:2000/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
EXTRARES,
"Url=/images/but_login.gif", "Referer=http://192.2.2.123:2000/login", ENDITEM,
LAST);
web_submit_form("login",
"Snapshot=t2.inf",
ITEMDATA,
"Name=username", "Value=admin", ENDITEM,
"Name=password", "Value=admin", ENDITEM,
"Name=Submit", "Value=", ENDITEM,
EXTRARES,
"Url=/images/bg_nav_menu_level1.gif", "Referer=http://192.2.2.123:2000/navigator", ENDITEM,
"Url=/images/bg_nav_menu_level2.gif", "Referer=http://192.2.2.123:2000/navigator", ENDITEM,
"Url=/images/bg_bar_blue.gif", "Referer=http://192.2.2.123:2000/system/status/status", ENDITEM,
"Url=/images/bg_foot.gif", "Referer=http://192.2.2.123:2000/footer", ENDITEM,
"Url=/images/bg_button.gif", "Referer=http://192.2.2.123:2000/system/status/status", ENDITEM,
"Url=/images/bg_nav_menu_level1_over.gif", "Referer=http://192.2.2.123:2000/navigator", ENDITEM,
"Url=/images/bg_nav_menu_level1_open.gif", "Referer=http://192.2.2.123:2000/navigator", ENDITEM,
"Url=/images/bg_nav_menu_level2_over.gif", "Referer=http://192.2.2.123:2000/navigator", ENDITEM,
"Url=/images/bg_nav_menu_level2_open.gif", "Referer=http://192.2.2.123:2000/navigator", ENDITEM,
LAST);
web_url("button",
"URL=http://192.2.2.123:2000/button?button=address,addr_group&button_url=/firewall/address/address,/firewall/address/group",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.123:2000/home",
"Snapshot=t3.inf",
"Mode=HTML",
EXTRARES,
"Url=/images/but_of.gif", "Referer=http://192.2.2.123:2000/button?button=address,addr_group&button_url=/firewall/address/address,/firewall/address/group", ENDITEM,
"Url=/images/but_lo.gif", "Referer=http://192.2.2.123:2000/button?button=address,addr_group&button_url=/firewall/address/address,/firewall/address/group", ENDITEM,
"Url=/images/but_rf.gif", "Referer=http://192.2.2.123:2000/button?button=address,addr_group&button_url=/firewall/address/address,/firewall/address/group", ENDITEM,
LAST);
web_url("address",
"URL=http://192.2.2.123:2000/firewall/address/address",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.123:2000/home",
"Snapshot=t4.inf",
"Mode=HTML",
LAST);
web_url("dlg",
"URL=http://192.2.2.123:2000/firewall/address/dlg",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.123:2000/home",
"Snapshot=t5.inf",
"Mode=HTML",
LAST);
lr_think_time(9);
##################################################
#建立第一个IP地址的操作,后面输入IP的操作都是和这个一样的
#####################################################
web_submit_form("dlg_2",
"Snapshot=t6.inf",
ITEMDATA,
"Name=addrname", "Value=1", ENDITEM,
"Name=addrtype", "Value=1", ENDITEM,
"Name=ipaddr", "Value=1.1.1.1", ENDITEM,
"Name=netmask", "Value=255.255.255.0", ENDITEM,
"Name=confirmbutton", "Value=确定", ENDITEM,
LAST);
web_url("msgdlg",
"URL=http://192.2.2.123:2000/common/common/msgdlg?list=/firewall/address/address&msg=%B2%D9%D7%F7%B3%C9%B9%A6%21",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.123:2000/home",
"Snapshot=t7.inf",
"Mode=HTML",
LAST);
web_url("address_2",
"URL=http://192.2.2.123:2000/firewall/address/address",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.123:2000/home",
"Snapshot=t8.inf",
"Mode=HTML",
LAST);
web_url("dlg_3",
"URL=http://192.2.2.123:2000/firewall/address/dlg",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.123:2000/home",
"Snapshot=t9.inf",
"Mode=HTML",
LAST);
lr_think_time(8);
############################################################
#这里为建立第二个IP地址的操作,循环操作的第一次
############################################################
web_submit_form("dlg_4",
"Snapshot=t10.inf",
ITEMDATA,
"Name=addrname", "Value=2", ENDITEM,
"Name=addrtype", "Value=1", ENDITEM,
"Name=ipaddr", "Value=1.1.1.2", ENDITEM,
"Name=netmask", "Value=255.255.255.0", ENDITEM,
"Name=confirmbutton", "Value=确定", ENDITEM,
LAST);
web_url("msgdlg_2",
"URL=http://192.2.2.123:2000/common/common/msgdlg?list=/firewall/address/address&msg=%B2%D9%D7%F7%B3%C9%B9%A6%21",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.123:2000/home",
"Snapshot=t11.inf",
"Mode=HTML",
LAST);
web_url("address_3",
"URL=http://192.2.2.123:2000/firewall/address/address",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.2.2.123:2000/home",
"Snapshot=t12.inf",
"Mode=HTML",
EXTRARES,
"Url=/theme/images/twistie_expanded.gif", ENDITEM,
LAST);
return 0;
} 我是想把上面的脚本改成一个循环,进行任意次循环执行上面建立地址对象的操作。(地址名和IP地址都是递增的)
看了loadrunner的资料,还是不大明白,该怎么改写。象snapshot,"dlg_2"应该都随循环递增是吧,但是不知道怎么修改
请知道的兄弟帮忙做个简单的示例,刚刚学习这个软件,十分感谢
谢谢3楼的兄弟 那你把"登录防火墙"部分放入Vuser_init中,建立IP地址操作放在Action中进行addrname,ipaddr,netmask(如果Mask地址会不同)参数化。 楼上的兄弟能否具体点?针对我上面录的脚本。
象snapshot,"dlg_2"应该都随循环递增是吧,但是不知道怎么修改
在循环里怎么参数化这些东东呢? 在最前面定一个一个变量 int i;
for (i=1;i<=你需要循环输入的次数;i++)
{
web_submit_form("dlg_2",
"Snapshot=t6.inf",
ITEMDATA,
"Name=addrname", "Value=1", ENDITEM,
"Name=addrtype", "Value=1", ENDITEM,
"Name=ipaddr", "Value={参数化1}", ENDITEM,
"Name=netmask", "Value={参数化2}", ENDITEM,
"Name=confirmbutton", "Value=确定", ENDITEM,
LAST);
lr_think_time(8);
}
把脚本中中文我修改的地方做成参数化,指向param list中的对应参数名,然后你将你需要的ip地址丢在参数列表中即可,记得把取值方式改成顺序+每次取值更新
[ 本帖最后由 云层 于 2008-12-24 16:52 编辑 ] addname和addtype酌情参数化,我不知道这两个属性干嘛的,如果静止重复,那么就定义成参数,并且设置唯一性取值就行了 那snapshot=t6.inf,web_submit_form("dlg_2",里的dlg_2这些是否也要参数化?
addname和addtype的参数化现在可以搞定了 还有 脚本在编译的时候出错
Action.c (69): illegal statement termination
Action.c (69): skipping `int'
Action.c (69): undeclared identifier `i'
c:\\program files\\hp\\loadrunner\\scripts\\\320\302\275\250\265\330\326\267\\\\combined_\320\302\275\250\265\330\326\267.c (5): 3 errors, not writing pre_cci.ci
我申明了int i;的啊 要包括什么头文件? 顶起来 求助 顺便谢谢楼上的两位兄弟! 菜鸟新学,请知道的兄弟不吝赐教啊
页:
[1]