创建代码模块

通过点击工具栏上的’Add Code Module’按钮,创建一个新的代码模块。

 7-rx-addcodemodule-5d

用例工具栏按钮添加一个新的代码模块

另外,您可以使用测试套件中的右键菜单添加一个新的代码模块。

 7-rx-addcodemodulecontextmenu-a5

使用右键菜单添加一个新的代码模块

7-rx-newcodemodule-36

指定代码模块的名称

点击“创建”按钮后,项目中会自动添加一个新的文件,并且在文件视图中自动打开。Ranorex Studio会创建一个新的测试模块类,它包含一个“Run”的方法,可以用来进行扩展自动化测试代码。

C#

namespace KeePass
{
/// <summary>
/// Description of AddCredentialEntry.
/// </summary>
[TestModule(“03F5603B-0DDC-49AA-8C26-4D8088260C66″, ModuleType.UserCode, 1)]
public class AddCredentialEntry : ITestModule
{
/// <summary>
/// Constructs a new instance.
/// </summary>
public AddCredentialEntry()
{
// Do not delete – a parameterless constructor is required!
}

/// <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(ITestModule)”/> method
/// that will in turn invoke this method.</remarks>
void ITestModule.Run()
{
Mouse.DefaultMoveTime = 300;
Keyboard.DefaultKeyPressTime = 100;
Delay.SpeedFactor = 1.0;
}
}
}

 

VB.NET

Namespace KeePass
”’ <summary>
”’ Description of AddCredentialEntry.
”’ </summary>
<TestModule(“03F5603B-0DDC-49AA-8C26-4D8088260C66″, ModuleType.UserCode, 1)> _
Public Class AddCredentialEntry
Implements ITestModule
”’ <summary>
”’ Constructs a new instance.
”’ </summary>
‘ Do not delete – a parameterless constructor is required!
Public Sub New()
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(ITestModule)”/> method
”’ that will in turn invoke this method.</remarks>
Private Sub ITestModule_Run() Implements ITestModule.Run
Mouse.DefaultMoveTime = 300
Keyboard.DefaultKeyPressTime = 100
Delay.SpeedFactor = 1.0
End Sub
End Class
End Namespace

 

 

Leave a comment

请输入正确的验证码