loadrunner12.55:脚本语言选择,C语言 or JavaScript
LR默认选择的时C语言作为脚本语言使用,可以在录制前修改为使用JavaScript语言,注意:录制完成后无法再修改使用的语言
C语言脚本示例如下:
Action() { web_add_auto_header("Sec-Fetch-Dest", "frame"); web_add_auto_header("Sec-Fetch-Mode", "navigate"); web_add_auto_header("Sec-Fetch-Site", "same-origin"); web_add_auto_header("Upgrade-Insecure-Requests", "1"); web_add_auto_header("sec-ch-ua", "\"Google Chrome\";v=\"89\", \"Chromium\";v=\"89\", \";Not A Brand\";v=\"99\""); web_add_auto_header("sec-ch-ua-mobile", "?0"); web_url("welcome.pl", "URL=http://127.0.0.1:1080/cgi-bin/welcome.pl?signOff=true", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/", "Snapshot=t3.inf", "Mode=HTML", LAST); web_add_header("Origin", "http://127.0.0.1:1080"); web_add_auto_header("Sec-Fetch-User", "?1"); web_submit_data("login.pl", "Action=http://127.0.0.1:1080/cgi-bin/login.pl", "Method=POST", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/cgi-bin/nav.pl?in=home", "Snapshot=t4.inf", "Mode=HTML", ITEMDATA, "Name=userSession", "Value=131012.836046983zHDiQHcpHftVzzzHtAtDDpiDzfcf", ENDITEM, "Name=username", "Value=jojo", ENDITEM, "Name=password", "Value=bean", ENDITEM, "Name=login.x", "Value=53", ENDITEM, "Name=login.y", "Value=15", ENDITEM, "Name=JSFormSubmit", "Value=on", ENDITEM, LAST); web_revert_auto_header("Sec-Fetch-User"); web_image("SignOff Button", "Alt=SignOff Button", "Snapshot=t5.inf", LAST); return 0; }
JavaScript语言示例:
//"''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' //" Script Title : //" //" Script Date : Tue Apr 6 14:52:47 2021 //" //"''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' function Action() { web.addAutoHeader('Sec-Fetch-Dest', 'frame'); web.addAutoHeader('Sec-Fetch-Mode', 'navigate'); web.addAutoHeader('Sec-Fetch-Site', 'same-origin'); web.addAutoHeader('Upgrade-Insecure-Requests', '1'); web.addAutoHeader('sec-ch-ua', '\"Google Chrome\";v=\"89\", \"Chromium\";v=\"89\", \";Not A Brand\";v=\"99\"'); web.addAutoHeader('sec-ch-ua-mobile', '?0'); web.url( { name : 'welcome.pl', url : 'http://127.0.0.1:1080/cgi-bin/welcome.pl?signOff=true', resource : 0, recContentType : 'text/html', referer : 'http://127.0.0.1:1080/WebTours/', snapshot : 't1.inf', mode : 'HTML' } ); web.addHeader('Origin', 'http://127.0.0.1:1080'); web.addAutoHeader('Sec-Fetch-User', '?1'); web.submitData( { name : 'login.pl', action : 'http://127.0.0.1:1080/cgi-bin/login.pl', method : 'POST', recContentType : 'text/html', referer : 'http://127.0.0.1:1080/cgi-bin/nav.pl?in=home', snapshot : 't2.inf', mode : 'HTML', itemData : [ {name : 'userSession', value : '131040.252409883zHtADicpQiDDDDDDtAttcpcQHQ'}, {name : 'username', value : 'jojo'}, {name : 'password', value : 'bean'}, {name : 'login.x', value : '51'}, {name : 'login.y', value : '4'}, {name : 'JSFormSubmit', value : 'on'} ] } ); web.revertAutoHeader('Sec-Fetch-User'); web.image( { name : 'SignOff Button', alt : 'SignOff Button', snapshot : 't3.inf' } ); return 0; }