Tear down based on global parameter

Ask general questions here.
rsudhak
Posts: 72
Joined: Fri Jan 04, 2019 1:38 pm

Tear down based on global parameter

Post by rsudhak » Tue Jul 09, 2019 2:16 pm

Hi,

My current scenario is, I email a group of people after running a test.

1. I tried adding a global parameter (devmode = boolean). I trigger this test through a batch file, is it possible to pass on this variable through the batch file itself to ranorex agent?

2. Also, use a global parameter to enable and disable the email tear down

Thanks in advance

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

Re: Tear down based on global parameter

Post by odklizec » Tue Jul 09, 2019 2:53 pm

Hi,

1) I believe that all Ranorex command line parameters, should work just fine with agent command line? So this example should set a given value to global parameter and run test on agent of your choice?
Test.exe /pa:devmode =true /a:"AgentName"
As for second question, I'm sure this could be done in code ;) Please search the forum for setup/teardown code examples. I'm sure I remember a discussion, regarding disbabling setup/teardown section of test suite/test case.
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

rsudhak
Posts: 72
Joined: Fri Jan 04, 2019 1:38 pm

Re: Tear down based on global parameter

Post by rsudhak » Wed Jul 10, 2019 8:46 am

tried it, getting this error:
Failed to set value 'false' to variable 'DevMode'.
Field or property not found or not writeable.

Batch looks like below: test.exe /pa:DevMode=true /rc:PD_RegressionTest /rf:myReports\\%%R_%%Y-%%M-%%D-%%T-%%X

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

Re: Tear down based on global parameter

Post by odklizec » Wed Jul 10, 2019 10:54 am

Hi,

Are you sure there is defined global parameter DevMode in 'test' solution?
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

rsudhak
Posts: 72
Joined: Fri Jan 04, 2019 1:38 pm

Re: Tear down based on global parameter

Post by rsudhak » Thu Jul 11, 2019 8:04 am

All I did was added a global parameter and on the teardown email module, added a boolean variable and bound it to the global parameter.

The case is same throughout, so don't see why I would get this message.
One thing to note is , this parameter was previously devMode, which I then renamed it
Test.exe /pa:DevMode=FALSE/rc:PD_RegressionTest /rf:myReports\\%%R_%%Y-%%M-%%D-%%T-%%X

Failed to set value 'FALSE' to variable 'devMode'.
Field or property not found or not writeable.
Show/Hide Stacktrace
at Ranorex.Core.Data.ReflectionDataProvider.SetValue(CaseInsensitiveString variableName, String value, Boolean exceptionOnFail)at Ranorex.Core.Data.ReflectionDataProvider.SetValue(CaseInsensitiveString variableName, String value)at Ranorex.Core.Testing.TestModuleLeaf.ReportAndAddBindingToActivityStack(ReflectionDataProvider refDataProvider)at Ranorex.Core.Testing.TestModuleLeaf.RunInternal(DataContext parentDataContext, Int32 iteration, Int32 iterationCount, Boolean skipIteration)

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

Re: Tear down based on global parameter

Post by odklizec » Thu Jul 11, 2019 8:45 am

Hi,

I think the problem is, that Ranorex parameters (either global params or test case/smart folder params) are strings! So boolean variable used in code will not work with string parameter! You must either replace the boolean variable with string variable or convert content of binded string param to boolean.
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

rsudhak
Posts: 72
Joined: Fri Jan 04, 2019 1:38 pm

Re: Tear down based on global parameter

Post by rsudhak » Thu Jul 11, 2019 9:00 am

Hi,

This is how it looks :
Email module:
[TestVariable("90e8e15f-75e2-485f-9b97-25af980d5ec9")]
public bool DevMode { get; set; }


rxtst:
<param
name="DevMode"
value="FALSE">
</param>

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

Re: Tear down based on global parameter

Post by odklizec » Thu Jul 11, 2019 9:16 am

Hi,

If possible, please post entire solution. Thanks.

As I mentioned in previous post, Ranorex parameters are ALWAYS strings! It does not matter you created bool module variable. String parameter binded to bool variable will most probably not work ;)
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