关于用户登录时需要选择不同按钮的解决

来源:互联网 发布:啊哈算法2出了吗 编辑:程序博客网 时间:2024/05/21 00:45

背景描述:网站登录时,会提示选择不同的按按钮进行登录。

网络登录有三个按钮,访问登录界面时,返回头文件包含登录按钮ID,分别为1、2、3;如下为返回的头文件信息:

****** Response Header For Transaction With Id 3 ******
HTTP/1.1 200 OK
Date: Mon, 30 Dec 2013 06:39:28 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Set-Cookie: ASP.NET_SessionId=objgabmzbywgmeevi3dip12x; path=/; HttpOnly
Set-Cookie: buttonNum=3; path=/
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Content-Type: text/html; charset=utf-8
Content-Length: 25397

解决思路:1、关联返回的登录按钮ID

                     2、根据判断ID值,给按钮坐标赋值。                


/* -------------------------------------------------------------------------------

    Script Title       :
    Script Description :
                        
                        
    Recorder Version   : 8859
   ------------------------------------------------------------------------------- */

vuser_init()
{
    int btnX=0;
    int btnY=0;
    int btnNum=0;

    //web_add_cookie("Hm_lvt_1b939bae8cde99eb25e41f434a11f5ef=1388366803; DOMAIN=10.10.16.35");

//关联登录buttnonNum值

    web_reg_save_param("buttonNum",
        "LB=buttonNum=",
        "RB=; path=/",
        "Ord=1",
        "Search=ALL",
        LAST);


    web_url("Login.aspx",
        "URL=http://10.10.16.35/MemberCenter/Login.aspx?urlstr=%2fp2p%2fp2pDetail_3230.htm",
        "TargetFrame=",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t1.inf",
        "Mode=HTML",
        LAST);

    web_url("login.aspx",
        "URL=http://10.10.16.35/MemberCenter/login.aspx?op=getdata&_=1388386369477",
        "TargetFrame=",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://10.10.16.35/MemberCenter/Login.aspx?urlstr=%2fp2p%2fp2pDetail_3230.htm",
        "Snapshot=t2.inf",
        "Mode=HTML",
        LAST);



    /*登录*/

//根据不同的buttonNum,获取不同的坐标值:X,Y

    btnNum=atoi(lr_eval_string("{buttonNum}"));

    switch(btnNum) {

    case 1:
        btnX=83;
        btnY=21;
//        lr_output_message ("x=%d,y=%d", x,y);
        break;

    case 2:
        btnX = 41;
        btnY = 16;
        break;

    case 3:
        btnX = 53;
        btnY = 20;
        break;

    }

//变量转为参数,将变量str的值存到参数Param中
    lr_save_int(btnX,"button_x");
    lr_save_int(btnY,"button_y");

    lr_think_time(10);

    web_submit_data("Login.aspx_2",
        "Action=http://10.10.16.35/MemberCenter/Login.aspx?urlstr=%2fp2p%2fp2pDetail_3230.htm",
        "Method=POST",
        "TargetFrame=",
        "RecContentType=text/html",
        "Referer=http://10.10.16.35/MemberCenter/Login.aspx?urlstr=%2fp2p%2fp2pDetail_3230.htm",
        "Snapshot=t3.inf",
        "Mode=HTML",
        ITEMDATA,
        "Name=__VIEWSTATE", "Value=/wEPDwULLTExNzc4ODUxODcPZBYCAgMPZBYEZg9kFgICAQ8WAh4EVGV4dAWsAeaCqOWlve+8jOasoui/juadpeWIsOWQiOaLjeWcqOe6v++8gTxhIGhyZWY9Ii9NZW1iZXJDZW50ZXIvbG9naW4uYXNweCIgaWQ9ImxpbmtHb0xvZ2luIj5b6ams5LiK55m75b2VXTwvYT48YSBocmVmPSIvTWVtYmVyQ2VudGVyL3JlZy5hc3B4IiBpZD0ibGlua0dvUmVnIj5b5YWN6LS55rOo5YaMXTwvYT5kAgkPZBYCAgEPFgIfAAXpAeWcsOWdgO+8mua3seWcs+W4guemj+eUsOWMuua7qOays+Wkp+"
        "mBkzUwMjLlj7cgIDxhIGhyZWY9Imh0dHA6Ly9nZGNhaW5mby5taWl0YmVpYW4uZ292LmNuLyIgdGFyZ2V0PSJfYmxhbmsiPueypElDUOWkhzEzMDUzMDE05Y+3PC9hPiAg54mI5p2D5omA5pyJPGZvbnQgc3R5bGU9ImZvbnQtZmFtaWx5OkFyaWFsOyI+wqk8L2ZvbnQ+5rex5Zyz5biC5ZCI5ouN5Zyo57q/55S15a2Q5ZWG5Yqh5pyJ6ZmQ5YWs5Y+4ZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WBAUEYnRuMQUEYnRuMgUEYnRuMwUEYnRuNFpFCr9/kqIIUxfGyY1oDuzlyk/E", ENDITEM,
        "Name=__VIEWSTATEGENERATOR", "Value=02D8A162", ENDITEM,
        "Name=Header1$hdlogin_header", "Value=0", ENDITEM,
        "Name=uname", "Value=liuyl", ENDITEM,
        "Name=password1", "Value=1", ENDITEM,
        "Name=code_phone", "Value=", ENDITEM,
        "Name=hd_login_way", "Value=0", ENDITEM,
        "Name=btn{buttonNum}.x", "Value={button_x}", ENDITEM,
        "Name=btn{buttonNum}.y", "Value={button_y}", ENDITEM,
        LAST);

    web_url("p2pDetail_3230.htm",
        "URL=http://10.10.16.35/p2p/p2pDetail_3230.htm",
        "TargetFrame=",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t4.inf",
        "Mode=HTML",
        LAST);

    web_url("login.aspx_2",
        "URL=http://10.10.16.35/MemberCenter/login.aspx?op=getdata&_=1388386390128",
        "TargetFrame=",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://10.10.16.35/MemberCenter/Login.aspx?urlstr=%2fp2p%2fp2pDetail_3230.htm",
        "Snapshot=t5.inf",
        "Mode=HTML",
        LAST);

    //web_add_cookie("Hm_lvt_1b939bae8cde99eb25e41f434a11f5ef=1388366803,1388386391; DOMAIN=10.10.16.35");

    //web_add_cookie("Hm_lpvt_1b939bae8cde99eb25e41f434a11f5ef=1388386391; DOMAIN=10.10.16.35");

    //web_add_cookie("IESESSION=alive; DOMAIN=10.10.16.35");

    web_submit_data("cert.ashx",
        "Action=http://10.10.16.35/GetData/cert.ashx?op=2",
        "Method=POST",
        "TargetFrame=",
        "RecContentType=text/plain",
        "Referer=http://10.10.16.35/p2p/p2pDetail_3230.htm",
        "Snapshot=t6.inf",
        "Mode=HTML",
        ITEMDATA,
        "Name=t", "Value=1388386391802", ENDITEM,
        LAST);

    web_url("r.cgi",
        "URL=http://isdspeed.qq.com/cgi-bin/r.cgi?flag1=7818&flag2=21&flag3=1&2=1001&&1388386391730",
        "TargetFrame=",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://10.10.16.35/p2p/p2pDetail_3230.htm",
        "Snapshot=t7.inf",
        "Mode=HTML",
        LAST);

    web_url("thirdcert.html",
        "URL=http://10.10.16.35/thirdcert.html",
        "TargetFrame=",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://10.10.16.35/p2p/p2pDetail_3230.htm",
        "Snapshot=t8.inf",
        "Mode=HTML",
        LAST);

    /*完成登录*/

    return 0;
}

0 0
原创粉丝点击