Update global parameter from user code

Ask general questions here.
Posts: 2
Joined: Wed Mar 16, 2016 8:51 am

Update global parameter from user code

Post by carloagiletester » Thu May 28, 2020 1:12 pm

I have the next situation:
- i want to run a testcase conditionally depending on a situation in a previous testcase.
- i created a global parameter(RunRestart) for that with value ´Yes´
- i use this global parameter as a condition to run the next testcase (only if the value is ´Yes´)
- in the previous testcase i want to update the value to ´No´ under certain situations.
- i created user code in that previous testcase to handle the update off the global parameter to ´No´ if applicable
- what is the command form doing this?
I tried Testsuite.Current.Parameters[RunRestart] = "Yes";
This does however not recognize the RunStart parameter (build error)

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

Re: Update global parameter from user code

Post by odklizec » Fri May 29, 2020 8:15 am


In my opinion, the best solution is to bind a variable in recording/code module to global parameter instead of changing it from code. Changing global parameter from code means, that you will have to hardcoded the name of global parameter, which is not nice practice. Therefore, binding variable to parameter is much more recommended approach. For more details check this blog post:
https://www.ranorex.com/blog/sharing-da ... o-another/

Anyway, if you prefer to change the global parameter from code, it should look like this:
TestSuite.Current.Parameters["RunRestart"] = "Yes";
In other words, "RunRestart" (if it's a parameter name and not a variable) must be enclosed in double quotes!

For more examples, check this post:
https://www.ranorex.com/forum/editing-p ... tml#p36747
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