Highlighted
Absent Member.
Absent Member.
14648 views

AJAX TruClient Evaluate C

Jump to solution

Has anyone managed to get the Evaluate C step to work in AJAX TruCluent? I have tried heaps of different ways but I haven't been able to get even a simple test to work. I checked all of the documentation that I could find but they only gave examples for Evaluate Javascript. I know HP don't encourage you to use C in TruClient but there are some technologies that have C bindings but no Javascript bindings.

0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.
Absent Member.

I tried that but I received the error:

 

Evaluate C function Hello ** failed - an argument is invalid: 'Function Name': JavaScript exception 'ReferenceError: Hello is not defined (did you forget adding quotation marks?)' during evaluation

 

I was playing around with it again and I finally got it to work. My c-functions.h looks like this:

 

void main()
{

}

void Hello()
{
    lr_save_string("Hello World","Hello");
}

In my Evaluate C function I put 'Hello' as the argument. It appears that the single quotes are required which was why it wasn't working for me. I am not sure if I can pass parameters to the function but I will just use LoadRunner parameters for now.

View solution in original post

0 Likes
13 Replies
Highlighted
Honored Contributor.
Honored Contributor.

Hi Andrew,

 

Did you try adding your C functions to the C-functions.c file that is listed in the left hand navigation within Vugen (outside of the Firefox/TruClient environment)?

 

What kind of errors are you getting?

Highlighted
Absent Member.
Absent Member.

I tried that but I received the error:

 

Evaluate C function Hello ** failed - an argument is invalid: 'Function Name': JavaScript exception 'ReferenceError: Hello is not defined (did you forget adding quotation marks?)' during evaluation

 

I was playing around with it again and I finally got it to work. My c-functions.h looks like this:

 

void main()
{

}

void Hello()
{
    lr_save_string("Hello World","Hello");
}

In my Evaluate C function I put 'Hello' as the argument. It appears that the single quotes are required which was why it wasn't working for me. I am not sure if I can pass parameters to the function but I will just use LoadRunner parameters for now.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

Hi,

 

Could please let me know how to do radomization links using Ajax Tru Client? Also I would like to know how to print txt file using Ajax Tru Client?

 

I mean which User ID what data sending to the Server and what Server responding would like to print in .txt file during the execution?

 

Please help me ASAP and also contact me at ch_majid01@hotmail.com. Since I am working on different client so I will not able to received reponse on majid.inayat@nike.com.

 

Please Drop an mail at ch_majid01@hotmail.com. I will highly appreciated if you can reply ASAP.

 

 

Regards

Majid

0 Likes
Highlighted
Trusted Contributor.. Trusted Contributor..
Trusted Contributor..

I, too, am trying to write from TruClient to a log file. Were you able to figure this out?

 

I am randomly picking items from accordian/drop-down lists, but I need to be able to keep track of which links were hit and by which VUsers. I tried Javascript IO.write, but cannot get it to work, plus I do not even know if it is possible for me to "capture" which items were selected.

 

 

Randy at Deere
0 Likes
Highlighted
Absent Member.
Absent Member.

Hi All,

I worked on your query, below is a sample code for genrating random date using AJAX tru client and Cfuntions.c

*************************************************************************************************************************** 

void getDate(){
int i,j;

/*If you need to get some value from external parameter file*/

//lr_output_message(lr_eval_string("{p}"));     
//j=atoi (lr_eval_string("{p}"));

 

//i= rand()%30;

lr_save_int(rand()%100,"randnum");
lr_output_message(lr_eval_string("{randnum}"));
i=atoi(lr_eval_string("{randnum}"));
lr_save_datetime("%m/%d/%y %H:%M:%S %p", DATE_NOW, "currentDate");
if (i>0) {
lr_save_datetime("%m/%d/%y %H:%M:%S %p", DATE_NOW - (ONE_DAY*i), "next");
lr_output_message("Current Date and Time : %s",lr_eval_string("{currentDate}"));
lr_output_message("New/Next Date and Time : %s",lr_eval_string("{next}"));
}
else{
lr_save_datetime("%m/%d/%y %H:%M:%S %p", DATE_NOW - (ONE_DAY), "next");
lr_output_message("Current Date and Time : %s",lr_eval_string("{currentDate}"));
lr_output_message("Else New/Next Date and Time : %s",lr_eval_string("{next}"));
}


}

 

 

 

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Below is the java script in Tru Client

-------------------------------------------------

 

LR.evalC("getDate");
fromDate = LR.getParam("next");

LR.log("yields Date in log non-interactive mode.... :" + fromDate);

 

************************************************************************************************************************

 

I hope this helps you.

 

Please get back to me in case you need any help.

 

 

Best Regards,

Gaurav Gupta

mail:gaurav.9988@gmail.com

 

0 Likes
Highlighted
Absent Member.
Absent Member.

Please check my reply at the end of this post.

THX.

0 Likes
Highlighted
New Member.

Hi Balaji,

PFB answers to your queries,

 

1. Does the 1st line means 'getDate' function is called...? Yes, it is used to call the function.
2. Does the 2nd line means 'next' parameter value is saved to a variable 'fromDate' ....? yes i have created a parameter in the c script which is being used in java script. 
3. Does the LR.log means the output is written to 'Interactive Replay Log'...?yes it is used to write output to interactive replay log.

 

Thanks,

Gaurav Gupta

mail : gaurav.9988@gmail.com

0 Likes
Highlighted
Absent Member.
Absent Member.

Thanks Gaurav.

0 Likes
Highlighted
Absent Member.
Absent Member.

Hi Gaurav,

 

in one of our script prepared using AJAX true client protocol,we need to use Web functions in C function call like web_set_sockets_option, when i ran the using lr.evalC it is giving error as "Error -- Unresolved symbol : web_set_sockets_option".

 

I tried using other web functions and got the same error. PLease let me know if there is way to run these web funcions of LR in AJAX true client protocol. Thanks in advance.

 

 

Thank you,

Nagendra

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

I am getting the same issue...someone can help us ?

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

And you guys are definitely using the C-functions.c library? Because I have this code working in TruClient for FF, 11.52 as we speak.

 

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.