How to create the global variable?

Best practices, code snippets for common functionality, examples, and guidelines.
Valeriy777
Posts: 19
Joined: Wed Jun 24, 2020 1:15 pm

How to create the global variable?

Post by Valeriy777 » Tue Aug 04, 2020 7:59 am

Hi,

I need to create a global variable, that I can manage from a runner and handle in the code.

For example, my attempts:
1) I created a global variable GlobalParameter in the TestCase:
Screenshot_10.png
2) I try to bind it with Recording2, but there isnt't exist the Recording2 record in the bounding dropdown.
Screenshot_11.png
3) Even if I bound the GlobalParameter with OpenBrowser record - I can't handle this parameter in the code
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to create the global variable?

Post by odklizec » Tue Aug 04, 2020 8:27 am

Hi,

Could you please post entire test suite for review?
What Ranorex version do you use (make sure you are using most recent 9.3.2)?
And what code exactly do you use for manipulating global parameter?

You can read global parameter via code like this:

Code: Select all

string globalParam = TestSuite.Current.GetTestContainer("tcName").Parameters["globalParamName"];
And you can update it with this code:

Code: Select all

TestSuite.Current.GetTestContainer("tcName").Parameters["globalParamName"]="value";
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration