Test App wiping out script variable
Question ID: 108234
1
0

Im currently using LoadRunner 12.55. In my TruClient script, I use a variable named Location. This variable gets wiped out after navigating to the url being tested.

In my TruClient script, I set the variables Location to "South Carolina". The Location variable gets wiped out when replaying the script

It’s very probable that the url I’m testing (which is an Angular app) may use the variable Location as well so that may be what’s doing it.

The workaround is simple for me, just use a variable with a different name. But the remaining issue is that I just happen to notice this, this time but there are other scripts I have that use variables and I wasn’t aware that I had to coordinate my variable naming with the app developers. Any input would be great

Marked as spam
Posted by (Questions: 108, Answers: 6)
Asked on April 18, 2018 1:30 pm
88 views
Answers (1)
1
Private answer

The Location variable was losing scope. If you change the Location variable to be a Global variable, then it will hold its value no matter the step, action and iterations.

Posted below is an example of how to create a global variable from Micro Focus.

When the TruClient General Settings > Local > Simulate a new user on each iteration is selected, variables are cleared between iterations. You can create a global variable whose scope exists between iterations.

1. Add an Evaluate JavaScript step. In the Arguments sections add code to define the variable in the Init Block:

For example, Global.Location=''South Carolina''

The global prefix defines a global variable named Location.

2. After defining the variable, use it in the Run Block. For example, use the
variable to control script flow:

Hope this helps

Marked as spam
Posted by (Questions: 17, Answers: 266)
Answered on April 18, 2018 1:31 pm
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top