1.Analysis结果分析发送get请求

Action()  
{  
  
  
  
  
  
        web_url(  
            "hello",  
            "URL=http://111.231.103.117/#/index/",  
            LAST  
       );  
        web_url(  
            "hello2",  
            "URL=http://111.231.103.117/#/index/hello",  
            LAST  
       );  
        web_url(  
            "hello3",  
            "URL=http://111.231.103.117/#/index/hello/kaixuezhang",  
            LAST  
       );  
    return 0;  
}

LoadRunner——脚本开发与发送请求(十九)-小白菜博客
1676792265(1).png

1676792280(1).png

Action()  
{  
  
        web_custom_request("web_custom_request",  
        "URL=http://111.231.103.117/#/index/login.shtml?jsoncallback=password=12345678&name=imooc",  
        "Method=GET",  
        "Resource=0",  
        "RecContentType=text/plain",  
        "Referer=",  
        "Mode=HTTP",  
        "EncType=text/plain",  
  
        LAST);  
  
  
    return 0;  
}

2. web_submit_data发送get请求

Action()  
{  
  
    web_submit_data("get_with_param",  
                   "Method=GET",  
                    "Action=http://111.231.103.117/#/index/hello/args/kaixuezhang",  
                    "Snapshot=t7.inf",  
                    ITEMDATA,  
                    "Name=key","value=我是key",ENDITEM,  
                    "Name=value","value=我是value",ENDITEM,  
                      
                     LAST);  
    return 0;  
}

3. web_submit_data发送post请求

Action()  
{  
web_submit_data("我的post请求",  
                   "Method=POST",  
                    "Action=http://111.231.103.117/#/index/mypost",  
                    "Snapshot=t7.inf"  
                     LAST);  
    web_submit_data("我的post请求2",  
                   "Method=poat",  
                    "Action=http://111.231.103.117/#/index/mypost1",  
                    "Snapshot=t2.inf"  
                    ITEMDATA,  
                    "Name=username","value=我是姓名",ENDITEM,  
                    "Name=sex","value=我是性别",ENDITEM,  
//    我们发送json格式的post请求不用这个                  
//                     LAST);      
//    web_submit_data("我的post请求3",  
//                   "Method=poat",  
//                    "Action=http://111.231.103.117/#/index/mypost2",  
//                    "RecContentType=application/json",  
//                    "Snapshot=t2.inf"  
//                    ITEMDATA,  
//                    "Name=user","value=我是姓名",ENDITEM,  
//                    "Name=sex","value=我是性别",ENDITEM,  
//                      
//                     LAST);  
    return 0;  
}

4. web_custom_request函数发送get和post请求

Action()  
{    
    //GET 请求  
    web_custom_request("get_login",  
                       "URL=http://111.231.103.117/#/login?user=imooc&pwd=12345678",  
                       "Method=GET",  
                       "Resource=0",  
                       "Mode=HTML",  
                       "RecContentType=application/json",  
                       LAST );  
   
    //POST 请求提交form数据  
    web_custom_request("post_form_login",  
                       "URL=http://111.231.103.117/#/login",  
                       "Method=POST",  
                       "Resource=0",  
                       "Mode=HTML",  
                       "Body=user=Milton&pwd=Loveyp",  
                       LAST );  
    //POST 请求提交json数据  
    web_custom_request("post_json_login",  
                       "URL=http://111.231.103.117/#/login_login",  
                       "Method=POST",  
                       "Resource=0",  
                       "Mode=HTML",  
                       "EncType=application/json",  
                       "Body={\"user\":\"imooc\",\"pwd\":\"12345678\"}",  
                       LAST );  
   
    return 0;  
}