Global variable for all test projects

Best practices, code snippets for common functionality, examples, and guidelines.
theraviz
Posts: 111
Joined: Sun Apr 14, 2019 9:46 am

Global variable for all test projects

Post by theraviz » Fri Mar 06, 2020 7:31 pm

Hi,

As per my understanding global variables can be defined at test suite level. Is there a way to declare a global variable so that it can be accessed across all projects in a solution?

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

Re: Global variable for all test projects

Post by odklizec » Mon Mar 09, 2020 8:40 am

Hi,

As long as the individual project files are a part of the same TestSuite, you can bind them to Global Parameters, no mater to which project they belong to. In other words, files (recordings and code modules) from different Projects, could be binded to the same Global Parameters. Just add them to Test Suite of your choice.
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

User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

Re: Global variable for all test projects

Post by Stub » Mon Mar 09, 2020 8:58 am

My initial take on this was sharing the global variable across multiple test suites, but I'm unclear if that's a correct interpretation?

I know that my test solution has a test project with multiple test suites, and I have a few variables common to each test suite for consistency and ease of use.

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

Re: Global variable for all test projects

Post by odklizec » Mon Mar 09, 2020 9:14 am

Hi Stub,

Yeah, I too considered he means sharing variables between test suites? But as he specifically mentioned "projects", I answered "project files in the same test suite". We will see from his response ;)
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

theraviz
Posts: 111
Joined: Sun Apr 14, 2019 9:46 am

Re: Global variable for all test projects

Post by theraviz » Mon Mar 09, 2020 12:32 pm

[/quote]
odklizec wrote:
Mon Mar 09, 2020 9:14 am
Hi Stub,

Yeah, I too considered he means sharing variables between test suites? But as he specifically mentioned "projects", I answered "project files in the same test suite". We will see from his response ;)
Hi Odklizec,

Below is my project structure. As you see I have Project 1, 2 and 3. Now I need to define a global variable so that the recordings of my Test Suite A,B and C can access the same variable.

Ranorex Project.JPG

Now When we open the Global parameter Window from any recording accross the project I need to have my global parameter appearing there. In the below screenshot the variable is only accessible for Test Suite A. I need to know a place where I can define the same which can be accessed across all recordings in the whole solution.
Ranorex Project.JPG
You do not have the required permissions to view the files attached to this post.

User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

Re: Global variable for all test projects

Post by Stub » Mon Mar 09, 2020 3:29 pm

I don't know of a super-global variable list that is common across multiple Test Suites.

All of our Test Suites share the odd variable, but each is individual to that Test Suite. Our build system informs the Test Suite what the value is for that variable when it executes the tests in a Test Suite. I tweak them manually when I'm running from Ranorex Studio during test development.

You might define the variable value in code somewhere, and then have a Code Module which updates the Test Suite global parameter list when the tests run. Thus all Test Suites share the one value. Very awkward though.

User avatar
N612
Posts: 135
Joined: Mon Jul 11, 2016 4:01 pm

Re: Global variable for all test projects

Post by N612 » Mon Mar 09, 2020 3:55 pm

I personally would use a centralized data source and update the global parameter with the data source value at the start of each test suite. The below screenshots and attached 9.3 solution may help with achieving this in your solution if you do go this route.
You do not have the required permissions to view the files attached to this post.