Highlighted
New Member.
6966 views

How to randomly select a value(flight) from the drop box with correlation?

Jump to solution
0 Likes
1 Solution

Accepted Solutions
New Member.

Randomly selecting a flight from Arrival and depature drop down .Aborting the script if depart city =Arrival city.

Action()
{

int i;
int ncount;
char ParamName[100];
int j;
int ncount1;
char ParamName1[100];

web_set_sockets_option("SSL_VERSION", "TLS");

    lr_start_transaction("flights");
       
web_reg_save_param("depart","LB=<option value=\"","RB=\"","ORD=ALL",LAST);
web_reg_save_param("Arrive","LB=<option value=\"","RB=\"","ORD=ALL",LAST);

                   
    web_url("Search Flights Button", 
        "URL=http://127.0.0.1:1080/cgi-bin/welcome.pl?page=search", 
        "TargetFrame=body", 
        "Resource=0", 
        "RecContentType=text/html", 
        "Referer=http://127.0.0.1:1080/cgi-bin/nav.pl?page=menu&in=home", 
        "Snapshot=t3.inf", 
        "Mode=HTML", 
        LAST);

    web_reg_find("Text=Flight Selections", 
        LAST);


 ncount= atoi(lr_eval_string("{depart_count}"));
         
           for (i =1;i <= ncount;i++)
       {
           sprintf(ParamName, "{depart_%d}", i);
       
       
      // lr_output_message("Value of %s: %s",ParamName,lr_eval_string(ParamName));
           }
           
           lr_save_string(lr_paramarr_random("depart"),"depart1");
          lr_output_message("Value of %s:",lr_eval_string("{depart1}"));
           
           ncount1= atoi(lr_eval_string("{Arrive_count}")); 
  
           for (j =1;j <= ncount;j++)
       {
           sprintf(ParamName1, "{Arrive_%d}", j);
       
       
       //lr_output_message("Value of %s: %s",ParamName1,lr_eval_string(ParamName1));
       lr_save_string(lr_paramarr_random("Arrive"),"Arrive1");
          lr_output_message("Value of %s:",lr_eval_string("{Arrive1}"));
           }
           if (lr_eval_string("{Arrive1}")== lr_eval_string("{depart1}"))
           {
                   lr_error_message("Error: %s", "sameERROR");
        lr_abort();
           }

                                                                
    web_submit_data("reservations.pl", 
        "Action=http://127.0.0.1:1080/cgi-bin/reservations.pl", 
        "Method=POST", 
        "TargetFrame=", 
        "RecContentType=text/html", 
        "Referer=http://127.0.0.1:1080/cgi-bin/reservations.pl?page=welcome", 
        "Snapshot=t4.inf", 
        "Mode=HTML", 
        ITEMDATA
        "Name=advanceDiscount", "Value=0", ENDITEM
        "Name=depart", "Value={depart1}", ENDITEM
        "Name=departDate", "Value=02/07/2017", ENDITEM
        "Name=arrive", "Value={Arrive1}", ENDITEM
        "Name=returnDate", "Value=02/08/2017", ENDITEM
        "Name=numPassengers", "Value=1", ENDITEM
        "Name=seatPref", "Value=None", 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=37", ENDITEM
        "Name=findFlights.y", "Value=9", ENDITEM
        LAST);
    
    lr_end_transaction("flights",LR_AUTO);


    return 0;
}

 

View solution in original post

0 Likes
1 Reply
New Member.

Randomly selecting a flight from Arrival and depature drop down .Aborting the script if depart city =Arrival city.

Action()
{

int i;
int ncount;
char ParamName[100];
int j;
int ncount1;
char ParamName1[100];

web_set_sockets_option("SSL_VERSION", "TLS");

    lr_start_transaction("flights");
       
web_reg_save_param("depart","LB=<option value=\"","RB=\"","ORD=ALL",LAST);
web_reg_save_param("Arrive","LB=<option value=\"","RB=\"","ORD=ALL",LAST);

                   
    web_url("Search Flights Button", 
        "URL=http://127.0.0.1:1080/cgi-bin/welcome.pl?page=search", 
        "TargetFrame=body", 
        "Resource=0", 
        "RecContentType=text/html", 
        "Referer=http://127.0.0.1:1080/cgi-bin/nav.pl?page=menu&in=home", 
        "Snapshot=t3.inf", 
        "Mode=HTML", 
        LAST);

    web_reg_find("Text=Flight Selections", 
        LAST);


 ncount= atoi(lr_eval_string("{depart_count}"));
         
           for (i =1;i <= ncount;i++)
       {
           sprintf(ParamName, "{depart_%d}", i);
       
       
      // lr_output_message("Value of %s: %s",ParamName,lr_eval_string(ParamName));
           }
           
           lr_save_string(lr_paramarr_random("depart"),"depart1");
          lr_output_message("Value of %s:",lr_eval_string("{depart1}"));
           
           ncount1= atoi(lr_eval_string("{Arrive_count}")); 
  
           for (j =1;j <= ncount;j++)
       {
           sprintf(ParamName1, "{Arrive_%d}", j);
       
       
       //lr_output_message("Value of %s: %s",ParamName1,lr_eval_string(ParamName1));
       lr_save_string(lr_paramarr_random("Arrive"),"Arrive1");
          lr_output_message("Value of %s:",lr_eval_string("{Arrive1}"));
           }
           if (lr_eval_string("{Arrive1}")== lr_eval_string("{depart1}"))
           {
                   lr_error_message("Error: %s", "sameERROR");
        lr_abort();
           }

                                                                
    web_submit_data("reservations.pl", 
        "Action=http://127.0.0.1:1080/cgi-bin/reservations.pl", 
        "Method=POST", 
        "TargetFrame=", 
        "RecContentType=text/html", 
        "Referer=http://127.0.0.1:1080/cgi-bin/reservations.pl?page=welcome", 
        "Snapshot=t4.inf", 
        "Mode=HTML", 
        ITEMDATA
        "Name=advanceDiscount", "Value=0", ENDITEM
        "Name=depart", "Value={depart1}", ENDITEM
        "Name=departDate", "Value=02/07/2017", ENDITEM
        "Name=arrive", "Value={Arrive1}", ENDITEM
        "Name=returnDate", "Value=02/08/2017", ENDITEM
        "Name=numPassengers", "Value=1", ENDITEM
        "Name=seatPref", "Value=None", 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=37", ENDITEM
        "Name=findFlights.y", "Value=9", ENDITEM
        LAST);
    
    lr_end_transaction("flights",LR_AUTO);


    return 0;
}

 

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.