How to use reusable code that provides output in Recording

Experiences, small talk, and other automation gossip.
neerajnegi
Posts: 2
Joined: Mon Jan 15, 2018 7:22 am

How to use reusable code that provides output in Recording

Post by neerajnegi » Mon Jan 15, 2018 7:45 am

Hi Team,
I developed a user code collection class in which i created a method called
"public static decimal ConvertStringToDecimal(String param)" to convert fetched values from String to Decimal so that i can perform calculations over it. But the issue comes when accessing this method from Recording Module.

When I add this method using Add Action->From User Code Library, How can i get this value under some variable because there is no way i can this access the return value. There is a field called arguement(where i pass the string) but there is nothing where i can get this value.

Can you tell me the way to use this method under recording value and fetch its output in some variable?

Regards
Neeraj Negi

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

Re: How to use reusable code that provides output in Recording

Post by odklizec » Mon Jan 15, 2018 10:48 am

Hi,

You need to create a new Recording module variable, which you can access from the user code.

These two blog posts should help you with details:
https://www.ranorex.com/blog/custom-smart-actions/
https://www.ranorex.com/blog/sharing-da ... o-another/
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

neerajnegi
Posts: 2
Joined: Mon Jan 15, 2018 7:22 am

Re: How to use reusable code that provides output in Recording

Post by neerajnegi » Tue Jan 16, 2018 5:39 am

Hi,
Thanks for acknowledging but you guys misunderstood my query.
I am attaching the screenshots as well.
Query: I develop a user code method which I changed to 'public static Decimal XYZ(String s)' instead of 'public static void'.
So now, my user code method takes String value and return decimal value as it is not a void method.

Now when I use this method in my recording module using Add New Action->User Code->Select From Library. I did not find anything where I can retrieve this decimal value which is coming as output of this user code action.

Through Code Module, it is possible but my question is regarding the Recording Module.

PFA the screenshots for better understanding.
You do not have the required permissions to view the files attached to this post.

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: How to use reusable code that provides output in Recording

Post by krstcs » Tue Jan 16, 2018 3:21 pm

The Decimal class has a Parse(string input) method that does this already, why re-invent the wheel, so-to-speak?

decimal value = Decimal.Parse(string input);

https://msdn.microsoft.com/en-us/librar ... .110).aspx
Shortcuts usually aren't...