Highlighted
Frequent Contributor.
Frequent Contributor.
336 views

Truclient : Variable being used instead of its value in the Field under Test

Jump to solution

Hi team

Apologies for this very basic question but I am a beginner and hence trying to find out what my error is.

I have saved a Parameter value but when calling this Parameter value through a variable or on by the Parameter name itself, the object (textbox) seems to be typing the variable name or the Parameter name instead of its value.. What am i doing wrong?

Example:

var entity = TC.getParam("Entity")   // Note : this holds a value  101

But when i use this   variable in my preceding step, where the object is identified and has to input the value, it types the variable name instead

ie

Type entity in EntityTextBox  // Note entity is the variable used above and EntityTextBox is the field  under test

 

Output : entity is entered in the textbox EntityTextBox instead of 101.


Any thoughts as to what I am doing wrong here?

Thanks
Thani

0 Likes
1 Solution

Accepted Solutions
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: Truclient : Variable being used instead of its value in the Field under Test

Jump to solution

Try to disable "Simulate a new user on aech iteration"; by default this option is enabled. 

Lorenzo 

View solution in original post

0 Likes
9 Replies
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: Truclient : Variable being used instead of its value in the Field under Test

Jump to solution

Hi Thani, 

can you try, please, to use this formalism?

    object.value = TC.getParam("Entity");

This instruction must be entered in a "Evaluate JavaScript" step from "Toolbox". With this formalism, you can wrote the Entity param value on a form in your web page. 

Tell me if this can fix the problem,

Lorenzo

0 Likes
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: Truclient : Variable being used instead of its value in the Field under Test

Jump to solution

Hi Lorenzo

Appreciate your help.. .I can confirm that this is now working as per your instructions.


I now encounter issue , which has been discussed in below article and I have followed the steps but I am unable to resolve.

https://community.microfocus.com/t5/LoadRunner-User-Discussions/TC-global-JavaScript-var-support/td-p/554123

Issue: Unable to use a global variable across other blocks (Action & End) and any calling function.

Code Snipped

Init Block ;  Evaluate JS Script code block

Global.user ="admin";

Action Block : Evaluate JS Script code block

TC.Log("User : " + Global.user, "Status");

Output:
User : undefined.

Any thoughts as to what I am doing wrong here?

 

Thanks
Thani

 

0 Likes
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: Truclient : Variable being used instead of its value in the Field under Test

Jump to solution

Sorry Thani, 

have you checked the "Simulate a new user for each iteration" from Runtime Settings? If you have an execution logic with a loop (init+action+end) you have to disable this option. Try and let me know. 

Lorenzo

0 Likes
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: Truclient : Variable being used instead of its value in the Field under Test

Jump to solution

 Hi Lorenzo

Forgot to mention that there are no loops or iterations and only a single user playback.

Hence this should be straightfoward right?

 

Thani

0 Likes
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: Truclient : Variable being used instead of its value in the Field under Test

Jump to solution

Hi Thani, 

if you have some actions on "Init", "End" and "Action" pages, you have to disable the "Simulate a new user on each iteration", because if not you, you will see a blank web page when you execute the "Action" page section after the "Init" section execution. 

This execution logic is for loop operation, so if you have to do a massive test (also with a single user) on all the steps included in the "Action" section, on the Scenario you can fix a duration and the "Action"'s operations will be executed repeatibly for the time you set. 

Try to disable this option, and tell me if something has changed.

Lorenzo

0 Likes
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: Truclient : Variable being used instead of its value in the Field under Test

Jump to solution

Hi Lorenzo

I am unable to find the option for "Simulate a new user for each iteration" under "Runtime Settings".

I am using VU Gen 12.6

See attached screenshot . I have circled the sections where i have looked to find this option but in vain

Do you know where I can find this option?

Thanks
Thani

0 Likes
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: Truclient : Variable being used instead of its value in the Field under Test

Jump to solution

Hi Thani,

you can find "Simulate a new user on each iteration" on "Runtime Settings" page under "Replay -> General",

simulateNewUser.PNG

Let me know!

Lorenzo

0 Likes
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: Truclient : Variable being used instead of its value in the Field under Test

Jump to solution

Try to disable "Simulate a new user on aech iteration"; by default this option is enabled. 

Lorenzo 

View solution in original post

0 Likes
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: Truclient : Variable being used instead of its value in the Field under Test

Jump to solution

Thanks Lorenzo . I have disabled the "Simulate a new user on each iteration option" and it has worked.. 🙂

I can confirm that this issue is now resolved and I am able to access the values declared in global variables across any of the blocks as it is getting persisted 

 

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.