Script Recorder Module
- 4 minutes to read
The XAF includes its own functional testing engine - EasyTest. EasyTest is specifically designed to simplify functional testing of XAF WinForms or ASP.NET Web Forms applications. The Script Recorder Module supplies you with a script recorder, which can record the actions you perform on a UI, and save them to an EasyTest script file. When using the script recorder, recording is performed via a set of Actions available in the Tools menu. Compared to manually writing test scripts, the script recorder allows you to create test scripts in a much more intuitive way. This topic details the basics of using the script recorder.
Note
The ScriptRecorder module does not work in ASP.NET Core Blazor applications.
The Script Recorder Module is represented by two module projects:
ScriptRecorderWindowsFormsModule
You can add this module to the Windows Forms application project. To do this, invoke the Application Designer and drag the ScriptRecorderWindowsFormsModule from the Toolbox to the Modules panel. Do not forget to rebuild your solution after making changes in a Designer.
-
You can add this module to your ASP.NET Web Forms application project. To do this, invoke the Application Designer and drag the ScriptRecorderAspNetModule from the Toolbox to the Modules panel. Do not forget to rebuild your solution after making changes in a Designer.
Note
You can add modules to your application when you use the Solution Wizard to create a new XAF solution. Select modules in the Choose Additional Modules step.
- To add an extra module in code, add it to the XafApplication.Modules or ModuleBase.RequiredModuleTypes list (adding a reference to the module assembly is insufficient).
In .NET applications, you can call the AddScriptRecorder(IModuleBuilder<IWinApplicationBuilder>) method in your WinForms application builder.
The script recorder is enabled when a debugger is attached to the application’s process or when you add the Module in the application builder. This behavior can be overridden by setting the DevExpress.ExpressApp.ScriptRecorder.ScriptRecorderControllerBase class’ nullable Boolean static ScriptRecorderEnabled property. To enable the script recorder, set this property to true. To permanently disable the script recorder, set this property to false. You can do this, for instance, in the application’s Global.asax.cs (Global.asax.vb) or Program.cs (Program.vb) file.
The script recorder is represented by three Actions assigned to the Tools Action Container.
- Pause/Resume Recording - Pauses or resumes script recording.
- Show Script - Invokes the script editing dialog. You can manually correct a script being recorded via this Action.
- Save Script - Saves the currently recorded script to a script file.
If the script recorder is enabled, it is activated from the application start in a recording mode. So the recorded script logs the actions you perform, including logging on to the application.
Note
Please remember that the script recorder does not provide ready-to-use scripts. In most cases, you are required to manually tune the script; refer to the list below.
- You should manually add commands that test the displayed data (CheckTable, CheckFieldValues, CheckValidationResult, etc.)
- The Script Recorder produces a script specific to the platform it was launched on (Windows Forms or ASP.NET Web Forms). There may be a difference in data formatting and in controls captions. Some steps of the script can be platform-specific (for example, switching a Detail View to an edit mode). To create a platform-agnostic script, manual editing is required (for example, the use of IfDef/EndIf directives and platform-agnostic commands). Refer to the EasyTest Script Reference topic for details.
- The Script Recorder is not aware of EasyTest configuration settings, so it cannot “guess” the valid application name that is to be passed to the Application command. You should change the name manually, and possibly add a second Application command to create a script for two platforms (Windows Forms and ASP.NET Web Forms).
- Manually add DropDB and RestoreDB commands when required.
The Script Recorder module is demonstrated in the Feature Center Demo, installed with XAF in the %PUBLIC%\Documents\DevExpress Demos 24.2\Components\XAF\FeatureCenter.NETFramework.XPO folder. Refer to the Feature Center demo online to see this module in action.