Pass parameters globally through cmd

Ask general questions here.
JayVatsa
Posts: 2
Joined: Thu Feb 28, 2019 1:58 pm

Pass parameters globally through cmd

Post by JayVatsa » Thu Feb 28, 2019 2:02 pm

Hi All,

Can anyone help me how to pass parameters globally through command prompt as i am creating a new item(in my application) and pass the item name using command prompt.

Thanks,
Joginder

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

Re: Pass parameters globally through cmd

Post by odklizec » Thu Feb 28, 2019 2:18 pm

Hi,

You can do it via this parameter:
/param|pa:[global parameter name]=[value]
For more details and command line parameters, check this user guide chapter:
https://www.ranorex.com/help/latest/ran ... earguments
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

JayVatsa
Posts: 2
Joined: Thu Feb 28, 2019 1:58 pm

Re: Pass parameters globally through cmd

Post by JayVatsa » Thu Feb 28, 2019 2:29 pm

Hi,

I am not able to understand as i am new to Ranorex.
Below is my userCode method and i want to pass the ("Iten35") through cmd which is name for some field in my app.
Could you please help me in this?

public void Key_sequence_Edit(RepoItemInfo argument1)
{
Report.Log(ReportLevel.Info, "Keyboard", "Key sequence 'Iten35' with focus on 'textInfo'.", argument1);
argument1.FindAdapter<Text>().PressKeys("Iten35");

}
Ranorex.PNG
Thanks,
Joginder
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: Pass parameters globally through cmd

Post by odklizec » Thu Feb 28, 2019 2:43 pm

Hi,

Well, the problem is, that you probably don't know basics and diving in user code without general knowledge of passing data from command line and between modules is not a very good idea ;) Here we go...

At first, you must create a Global Parameter at user Test Suite level (let's call it itemName).
At next, you must create a string variable in code/recording module, in which you are using your method (let's call it itemName as well).
Now you must extend the method with string parameter (you can also call it itemName), like this:

Code: Select all

public void Key_sequence_Edit(RepoItemInfo argument1, string itemName)
{
Report.Log(ReportLevel.Info, "Keyboard", "Key sequence '" + itemName + "' with focus on 'textInfo'.", argument1);
argument1.FindAdapter<Text>().PressKeys(itemName);
}
Now you must bind Global Parameter itemName with module variable itemName. If you did everything as described above, global parameter should be successfully passed to your method. Hope this helps?

I would also recommend you to read this blog post, describing sharing data between modules in more details...
https://www.ranorex.com/blog/sharing-da ... o-another/

BTW, is there a reason, why you are converting everything in recording module to user code? I would strongly recommend to stick with recording module actions wherever possible and use code only if absolutely necessary. Especially if you are new to Ranorex, you should stick with recording modules and predefined actions. Using code, without a good reason and very good knowledge of Ranorex, is a sure way to errors and confusion.
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