Hi,
I need a common Sub how can I do that ?
Lets I have function in user code and I want to call it from different modules, how can I do that ? Currently I can only call functions from its recording module.
Common function to call from different recording modules
Re: Common function to call from different recording modules
Hi,
You can achieve this by 'inheritance'. You can find a very nice tutorial with description in this blog post...
http://www.ranorex.com/blog/custom-smar ... readAction
You can achieve this by 'inheritance'. You can find a very nice tutorial with description in this blog post...
http://www.ranorex.com/blog/custom-smar ... readAction
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
Re: Common function to call from different recording modules
Isn there any other way instead of creating a class ? Does has to be object oriented ?
Re: Common function to call from different recording modules
Hi,
What's the problem with suggested "common" class and inheritance? It's pretty easy to setup and use. I don't know about any other way to achieve what you've requested.
What's the problem with suggested "common" class and inheritance? It's pretty easy to setup and use. I don't know about any other way to achieve what you've requested.
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
-
- Posts: 254
- Joined: Tue Mar 24, 2015 5:05 pm
- Location: Des Moines, Iowa, USA
Re: Common function to call from different recording modules
I agree that using class inheritance is overkill for something so simple as a common module, but Ranorex doesn't seem to allow you to import from modules.
A potential work around is to add a module. Added your sub to the module you just created. We'll call the sub "EatCheese".
Then in the recorded module, you'll add a new usercode step called "PointsToEatCheese"
Then in the usercode file you'll call "EatCheese" directly
The IDE is smart enough that the EatCheese sub in the shared module will appear in the IntelliSense.
You'll just want to make sure your signatures match in both cases so you can appropriately pass arguments between the usercode step and the shared module sub.
Unfortunately I don't know of a way to get "EatCheese" to be listed in the available coded steps when you try to add a coded step from the recorded module UI directly. If that is a requirement, you'll probably need to stick to the inheritance method or submit a feature request to the powers that be.
A potential work around is to add a module. Added your sub to the module you just created. We'll call the sub "EatCheese".
Code: Select all
Public Module Module1
Public Sub EatCheese
'Do stuff
End Sub
End Module
Code: Select all
Public Partial Class Recording1
''' <summary>
''' This method gets called right after the recording has been started.
''' It can be used to execute recording specific initialization code.
''' </summary>
Private Sub Init()
' Your recording specific initialization code goes here.
End Sub
Public Sub PointsToEatCheese()
EatCheese()
End Sub
End Class
Unfortunately I don't know of a way to get "EatCheese" to be listed in the available coded steps when you try to add a coded step from the recorded module UI directly. If that is a requirement, you'll probably need to stick to the inheritance method or submit a feature request to the powers that be.
You do not have the required permissions to view the files attached to this post.
Doug Vaughan
Re: Common function to call from different recording modules
Tans Vaughan, that really helped !
-
- Posts: 254
- Joined: Tue Mar 24, 2015 5:05 pm
- Location: Des Moines, Iowa, USA
Re: Common function to call from different recording modules
No problem. Glad I could help.
Doug Vaughan
-
- Posts: 254
- Joined: Tue Mar 24, 2015 5:05 pm
- Location: Des Moines, Iowa, USA
Re: Common function to call from different recording modules
Updating this thread with new information. Ranorex 6.2 has incorporated this functionality into the tool.
Doug Vaughan