Sample of Shunra Transactions with Shunra NV for HP 8.6x in VuGen Scripts

Copy the following Shunra functions into your VuGen Scripts.

Shunra NV for HP 8.6 only

char *xstrcat( char *dest, char *src )

{

while (*dest) dest++;

while (*dest++ = *src++);

return –dest;

}

//Shunra – send REST request

SendRequest(char *requestType, char *uri,char *request_json_base)

{

char *request_type;

char *request_json;

lr_save_string(lr_eval_string(uri), "URL_Param");

request_json = lr_eval_string(request_json_base);

lr_save_string(request_json, "REQUEST_JSON_PARAM");

request_type=lr_eval_string(requestType);

lr_save_string(request_type,"REQ_TYPE");

web_add_header("Content-Type", "application/json");

web_reg_save_param("RESPONSE",

"Notfound=warning",

"LB=",

"RB=",

"Search=Body",

"IgnoreRedirections=Yes",

LAST);

web_custom_request("request",

"URL={URL_Param}",

"Method={REQ_TYPE}",

"TargetFrame=",

"Resource=0",

"Referer=",

"Mode=HTTP",

"Body={REQUEST_JSON_PARAM}",

LAST);

return 0;

}

//Shunra – start transaction manager session

ConnectTM()

{

char *request_json_base;

char *temp;

char *temp2;

char *lgip;

char URL[80];

web_set_sockets_option("IP_ADDRESS_BY_INDEX", "1");

lgip = lr_get_vuser_ip();

strcpy(URL,"http://");

xstrcat(URL,lgip);

xstrcat(URL,":8182/shunra/api/transactionmanager");

request_json_base=

"{"

"\"endpointIdentifier\":\"ID_CLIENT_FLOWS_1\","

"\"overwriteExistingConnection\":\"true\""

"}";

SendRequest("POST",URL, request_json_base);

temp=lr_eval_string("{RESPONSE}");

temp2=temp+1;

lr_save_string(temp2,"transactionManagerSessionIdentifiers");

return 0;

}

//Shunra – end transaction manager session

DisconnectTM()

{

char *request_json_base;

char *temp;

char *lgip;

char URL[80];

web_set_sockets_option("IP_ADDRESS_BY_INDEX", "1");

lgip = lr_get_vuser_ip();

strcpy(URL,"http://");

xstrcat(URL,lgip);

xstrcat(URL,":8182/shunra/api/transactionmanager");

request_json_base=

"{"

"{transactionManagerSessionIdentifiers}";

SendRequest("PUT",URL, request_json_base);

return 0;

}

//Shunra – mark start transaction

StartTransaction(char *TransactionName)

{

char *request_json_base;

char *temp;

char *temp2;

char *lgip;

char URL[80];

web_set_sockets_option("IP_ADDRESS_BY_INDEX", "1");

lgip = lr_get_vuser_ip();

strcpy(URL,"http://");

xstrcat(URL,lgip);

xstrcat(URL,":8182/shunra/api/transactionmanager/transaction");

lr_save_string(lr_eval_string(TransactionName),"TRANSACTION_NAME");

request_json_base="{"

"\"transactionName\":\""

"{TRANSACTION_NAME}"

"\","

"{transactionManagerSessionIdentifiers}";

SendRequest("POST",URL, request_json_base);

temp=lr_eval_string("{RESPONSE}");

memmove(temp, temp+1, (strlen(temp)-2));

temp[(strlen(temp)-2)]=0;

lr_save_string(temp,"transactionIdentifiers");

return 0;

}

//Shunra – mark stop transaction

StopTransaction(char *TransactionDescription)

{

char *temp;

char *temp2;

char *request_json_base;

char *lgip;

char URL[80];

web_set_sockets_option("IP_ADDRESS_BY_INDEX", "1");

lgip = lr_get_vuser_ip();

strcpy(URL,"http://");

xstrcat(URL,lgip);

xstrcat(URL,":8182/shunra/api/transactionmanager/transaction");

lr_save_string(lr_eval_string(TransactionDescription),"TRANSACTION_Description");

request_json_base="{"

"\"transactionDescription\":\""

"{TRANSACTION_Description}"

"\","

"\"passed\":\"true\","

"{transactionIdentifiers}"

","

"{transactionManagerSessionIdentifiers}";

SendRequest("PUT",URL, request_json_base);

temp=lr_eval_string("{RESPONSE}");

temp2=temp+1;

lr_save_string(temp2,"transactionStop");

return 0;

}

Action()

{

//Connect to Shunra TM

ConnectTM();

web_url("172.31.3.43",

"URL=http://172.31.3.43/",

"Resource=0",

"RecContentType=text/html",

"Referer=",

"Snapshot=t1.inf",

"Mode=HTML",

EXTRARES,

"Url=/demo.css", ENDITEM,

LAST);

StartTransaction("01_Login");

lr_start_transaction("01_Login");

web_url("mainmenu.gif",

"URL=http://172.31.3.43/bank_login.htm",

"TargetFrame=",

"Resource=0",

"RecContentType=text/html",

"Referer=http://172.31.3.43/",

"Snapshot=t2.inf",

"Mode=HTML",

EXTRARES,

"Url=/images/bank_logo.gif", ENDITEM,

LAST);

web_url("signon.gif",

"URL=http://172.31.3.43/bank_login2.htm",

"TargetFrame=",

"Resource=0",

"RecContentType=text/html",

"Referer=http://172.31.3.43/bank_login.htm",

"Snapshot=t3.inf",

"Mode=HTML",

LAST);

lr_think_time(4);

web_url("PRESS HERE",

"URL=http://172.31.3.43/bank1.htm",

"TargetFrame=",

"Resource=0",

"RecContentType=text/html",

"Referer=http://172.31.3.43/bank_login2.htm",

"Snapshot=t4.inf",

"Mode=HTML",

LAST);

lr_end_transaction("01_Login",LR_AUTO);

StopTransaction("01_Login");

lr_think_time(1);

StartTransaction("02_Credit Report");

lr_start_transaction("02_Credit Report");

web_url("Credit Report",

"URL=http://172.31.3.43/bank5bmp.htm",

"TargetFrame=",

"Resource=0",

"RecContentType=text/html",

"Referer=http://172.31.3.43/bank1.htm",

"Snapshot=t5.inf",

"Mode=HTML",

EXTRARES,

"Url=/images/back.gif", ENDITEM,

LAST);

lr_end_transaction("02_Credit Report",LR_AUTO);

StopTransaction("02_Credit Report");

lr_think_time(1);

web_url("back.gif",

"URL=http://172.31.3.43/bank1.htm",

"TargetFrame=",

"Resource=0",

"RecContentType=text/html",

"Referer=http://172.31.3.43/bank5bmp.htm",

"Snapshot=t6.inf",

"Mode=HTML",

LAST);

StartTransaction("03_Spending");

lr_start_transaction("03_Spending");

web_url("View Spending Report",

"URL=http://172.31.3.43/bank3.htm",

"TargetFrame=",

"Resource=0",

"RecContentType=text/html",

"Referer=http://172.31.3.43/bank1.htm",

"Snapshot=t7.inf",

"Mode=HTML",

LAST);

lr_end_transaction("03_Spending",LR_AUTO);

StopTransaction("03_Spending");

lr_think_time(1);

DisconnectTM();

return 0;

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s