51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2212|回复: 0
打印 上一主题 下一主题

[求助] 求助,新手入门,想插入一段C语言代码但是不知道插到哪里

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2014-5-29 15:32:37 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
如题,求助,新手入门,想插入一段C语言代码但是不知道插到哪里
Action:
Action()
{

        web_reg_find("Text=Web Tours",
                LAST);
        web_reg_find("Text=Web Tours",
                LAST);
   
        lr_start_transaction("logon");

        web_url("WebTours",
                "URL=http://127.0.0.1:1080/WebTours/",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=",
                "Snapshot=t1.inf",
                "Mode=HTML",
                LAST);

        lr_think_time(11);

   
        lr_rendezvous("tologon");

        web_submit_form("login.pl",
                "Snapshot=t2.inf",
                ITEMDATA,
                "Name=username", "Value=jojo", ENDITEM,
                "Name=password", "Value=bean", ENDITEM,
                "Name=login.x", "Value=27", ENDITEM,
                "Name=login.y", "Value=15", ENDITEM,
                LAST);

        lr_end_transaction("logon", LR_AUTO);

        lr_think_time(4);
   
        lr_start_transaction("fight");


        lr_start_transaction("find_confirm_flight");

        web_image("Search Flights Button",
                "Alt=Search Flights Button",
                "Snapshot=t3.inf",
                LAST);

        web_url("FormDateUpdate.class",
                "URL=http://127.0.0.1:1080/WebTours/FormDateUpdate.class",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=",
                "Mode=HTML",
                LAST);

        web_url("CalSelect.class",
                "URL=http://127.0.0.1:1080/WebTours/CalSelect.class",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=",
                "Mode=HTML",
                LAST);

        web_url("Calendar.class",
                "URL=http://127.0.0.1:1080/WebTours/Calendar.class",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=",
                "Mode=HTML",
                LAST);

        lr_think_time(72);

        web_submit_data("reservations.pl",
                "Action=http://127.0.0.1:1080/WebTours/reservations.pl",
                "Method=POST",
                "RecContentType=text/html",
                "Referer=http://127.0.0.1:1080/WebTours/reservations.pl?page=welcome",
                "Snapshot=t4.inf",
                "Mode=HTML",
                ITEMDATA,
                "Name=advanceDiscount", "Value=0", ENDITEM,
                "Name=depart", "Value=Denver", ENDITEM,
                "Name=departDate", "Value=05/14/2014", ENDITEM,
                "Name=arrive", "Value=Los Angeles", ENDITEM,
                "Name=returnDate", "Value=05/15/2014", ENDITEM,
                "Name=numPassengers", "Value=1", ENDITEM,
                "Name=seatPref", "Value={seat}", ENDITEM,
                "Name=seatType", "Value=Coach", ENDITEM,
                "Name=.cgifields", "Value=roundtrip", ENDITEM,
                "Name=.cgifields", "Value=seatType", ENDITEM,
                "Name=.cgifields", "Value=seatPref", ENDITEM,
                "Name=findFlights.x", "Value=32", ENDITEM,
                "Name=findFlights.y", "Value=7", ENDITEM,
                LAST);

        lr_think_time(11);

        web_submit_form("reservations.pl_2",
                "Snapshot=t5.inf",
                ITEMDATA,
                "Name=outboundFlight", "Value=030;251;05/14/2014", ENDITEM,
                "Name=reserveFlights.x", "Value=53", ENDITEM,
                "Name=reserveFlights.y", "Value=9", ENDITEM,
                LAST);

        lr_think_time(17);

        web_submit_form("reservations.pl_3",
                "Snapshot=t6.inf",
                ITEMDATA,
                "Name=firstName", "Value=Joseph", ENDITEM,
                "Name=lastName", "Value=Marshall", ENDITEM,
                "Name=address1", "Value=234 Willow Drive", ENDITEM,
                "Name=address2", "Value=San Jose/CA/94085", ENDITEM,
                "Name=pass1", "Value=Joseph Marshall", ENDITEM,
                "Name=creditCard", "Value=12345678", ENDITEM,
                "Name=expDate", "Value=06/10", ENDITEM,
                "Name=saveCC", "Value=<OFF>", ENDITEM,
                "Name=buyFlights.x", "Value=72", ENDITEM,
                "Name=buyFlights.y", "Value=15", ENDITEM,
                LAST);

        lr_end_transaction("fight", LR_AUTO);



        lr_think_time(7);

        web_url("welcome.pl",
                "URL=http://127.0.0.1:1080/WebTours/welcome.pl?page=itinerary",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=flights",
                "Snapshot=t7.inf",
                "Mode=HTML",
                LAST);




        lr_end_transaction("find_confirm_flight", LR_AUTO);

        lr_think_time(6);

        web_image("SignOff Button",
                "Alt=SignOff Button",
                "Snapshot=t8.inf",
                LAST);
        lr_output_message("the flight was booked");

return 0;
}

网上找的常用代码:
//(随机城市)
count=atoi(lr_eval_string("{city_count}"));     srand(time(NULL)); 
    depart_num=rand()%count+1;     if(depart_num= =18) 
       arrive_num=depart_num-1;     else 
       arrive_num=depart_num+1;  
    lr_output_message("起始城市下标为 %d,目的城市下标  
%d",depart_num,arrive_num); //输出语句 
 
    sprintf(rand_depart_city,"{city_%d}",depart_num);     sprintf(rand_arrive_city,"{city_%d}",arrive_num);     sprintf(depart,"Value=%s",rand_depart_city);     sprintf(arrive,"Value=%s",rand_arrive_city);
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-22 15:11 , Processed in 0.070692 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表