lzhdc 发表于 2010-11-3 10:17:27

LR中转换JS语言

login()
{

        lr_think_time(5);

        web_submit_data("login.pl",
                "Action=http://localhost:1080/mercuryWebTours/login.pl",
                "Method=POST",
                "RecContentType=text/html",
                "Referer=http://localhost:1080/mercuryWebTours/nav.pl?in=home",
                "Snapshot=t4.inf",
                "Mode=HTML",
                ITEMDATA,
                "Name=userSession", "Value=104389.62818955fDzQftVpfDccVHpctQ", ENDITEM,
                "Name=username", "Value={user}", ENDITEM,
                "Name=password", "Value={password}", ENDITEM,
                "Name=JSFormSubmit", "Value=off", ENDITEM,
                "Name=login.x", "Value=42", ENDITEM,
                "Name=login.y", "Value=6", ENDITEM,
                LAST);

        return 0;
}
请问这段代码怎么转换成JS语言?:handshake

jane_0506 发表于 2010-11-3 10:18:41

:handshake学习路过

skyzhu 发表于 2010-11-3 10:38:31

要转换是不可能的,只能说是发送一个差不多的HTTP包

1. 利用form加载直接submit
<body onload="javascript: form111.submit()">
<form name="form111" method="post" action="http://localhost:1080/mercuryWebTours/login.pl">
<input type="hidden" name="userSession" value="104389.62818955fDzQftVpfDccVHpctQ" />
<input type="hidden" name="username" value="username" />
<input type="hidden" name="password" value="password" />
<input type="hidden" name="JSFormSubmit" value="off" />
<input type="hidden" name="login.x" value="1" />
<input type="hidden" name="login.y" value="1" />
</form>
</body>

2. 利用ajax提交
if (window.XMLHttpRequest)
{xmlhttp = new XMLHttpRequest();}
else if (window.ActiveXObject)
{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}
xmlhttp.open('POST','http://localhost:1080/mercuryWebTours/login.pl',false);
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xmlhttp.send('userSession=104389.62818955fDzQftVpfDccVHpctQ&username=username&password=password&JSFormSubmit=off&login.x=1&login.y=1');

msnshow 发表于 2010-11-3 14:01:15

手工转换可以,自动嘛,估计还没现成的工具

lzhdc 发表于 2010-11-3 14:25:36

就是不知道怎么手工转换:(
页: [1]
查看完整版本: LR中转换JS语言