Page 1 of 1

passing parameters

Posted: Tue Mar 22, 2016 11:01 am
by giuseppe.lacagnina
Dear All,

I need to call the Ranorex test cases from another application, which essentially calls them from the command line also specifying some parameters. As far as I understand, the following format is supported:

/pa:MyParam = "the value of myParam"

However, I need also the following format to be supported:

"/pa:MyParam = the value of myParam"

would that be possible? Thanks in advance!

PS: the main point is that I need to pass parameters with spaces in their value.

Re: passing parameters

Posted: Tue Mar 22, 2016 3:17 pm
by Martin
The examples you gave and the main point you need (parameters with spaces in their values) don't really match anyway cause both of your examples use spaces and i'm not sure what you mean with the quotation marks ( " " ) in your examples (do you want to pass the whole "/pa:MyParam = the value of myParam" as a parameter?).

But coming back to your point about needing spaces in your values. I'm not sure if we can pass spaces as parameter values for command line arguments (maybe there does exists a placeholder for a space eg. %s or something) but I can offer you another solution to overcome the need for spaces in the values.

Following this document: http://www.ranorex.com/blog/defining-ex ... r-ui-test/

Basically you could define a new command line argument in the Program.cs file which in turn could contain the needed values and the value would be matched against some simple value from the command line argument eg. command line argument value 1 could match against string "some text with space" and value 2 could match against string "some other text with space". From there on you could basically do anything with the values like signing them to a parameter and etc.

Add the following code to the Main method

Code: Select all

string value = "something";

for (int i = 0; i < args.Length-1; i++)
{
    if (args[i] == "/yourMarker")
        value = args[i+1];
}
And when you have the value caught on startup you can add an if-else statement to match the value with correct behaviour.

And from command line you would pass it as: myTest.exe /yourMarker "value"


Edit: And actually as this method uses quotation marks it might be possible to even pass values with spaces (haven't tried myself) which would make this solution even easier for you.

Re: passing parameters

Posted: Tue Mar 22, 2016 3:21 pm
by giuseppe.lacagnina
I will think about it! Thanks!!!

Re: passing parameters

Posted: Tue Mar 22, 2016 3:43 pm
by giuseppe.lacagnina
I tested the possibility of running a test case directly from the command line with

myCase.exe /pa:DummyParameter="this has spaces"

and this works, the spaces are no problem.

Re: passing parameters

Posted: Tue Mar 22, 2016 3:51 pm
by Martin
Yes tried it as well and works fine with quotation marks. "/pa:myParameter=Value" on the other hand does not offer any functionality and is not recognized.

Re: passing parameters

Posted: Tue Mar 22, 2016 3:59 pm
by giuseppe.lacagnina
What you say makes perfect sense. I will see what I can do. Thanks a lot for your help!!!