Here is how I did it. I'm using Visual Basic (VB) and not C# CS in Ranorex.
In Ranorex
- "Add Code Module"
MainLibrary
- "Add Code Module"
StartBrowser
Comment out three code blocks in the code module MainLibrary
:
The first is
'Implements ITestModule
The second is
''' <summary>
''' Constructs a new instance.
''' </summary>
' Public Sub New()
' ' Do not delete - a parameterless constructor is required!
' End Sub
The third location is
''' <summary>
''' Performs the playback of actions in this module.
''' </summary>
''' <remarks>You should not call this method directly, instead pass the module
''' instance to the <see cref="TestModuleRunner.Run(Of ITestModule)"/> method
''' that will in turn invoke this method.</remarks>
' Sub Run() Implements ITestModule.Run
' Mouse.DefaultMoveTime = 300
' Keyboard.DefaultKeyPressTime = 100
' Delay.SpeedFactor = 1.0
' End Sub
Add Sub
(s) for the action(s) you want to call from the other code module(s)
Public Sub OpenBrowser
Host.Local.OpenBrowser("http://www.ranorex.com", "IE", "", False, False)
End Sub
In the code module, you are calling the method that's in MainLibrary
. Add the Inherits
statement before the Implements
statement, then call the method from the MainLibrary
in the ITestModule.Run
code block:
Public Class StartBrowser
Inherits MainLibrary
Implements ITestModule
''' <summary>
''' Constructs a new instance.
''' </summary>
Public Sub New()
' Do not delete - a parameterless constructor is required!
End Sub
''' <summary>
''' Performs the playback of actions in this module.
''' </summary>
''' <remarks>You should not call this method directly, instead pass the module
''' instance to the <see cref="TestModuleRunner.Run(Of ITestModule)"/> method
''' that will in turn invoke this method.</remarks>
Sub StartBrowser_Run() Implements ITestModule.Run
Mouse.DefaultMoveTime = 300
Keyboard.DefaultKeyPressTime = 100
Delay.SpeedFactor = 1.0
'Call the public method from MainLibrary Class.
OpenBrowser()
End Sub
End Class
On Ranorex's Website, it shows about creating library's that comes in handy when reusing for different projects.