When working with ReadyAPI, you may need to preprocess the project you open to make it work in the way you need. When you load a project, the project’s load script triggers, and when you save it, the save script triggers. This allows you to adapt the project to the computer it is run on, for example, by changing the workspace to the one prepared for the test.
Create Load and Save Scripts
You can create load and save scripts in the Project Settings dialog.
-
Right-click your project and select Project Settings.
-
Switch to the Load Script or Save Script tab.
This dialog uses the default ReadyAPI script editor.
Available Objects
You can use the following objects:
-
log
– the object used to work with ReadyAPI logs. -
project
– the object that provides access to the project you load or save.
Sample Scripts
Here are some sample scripts you can use to get started:
Set a Property Value
You can use this script as the load or save script depending on when you need to modify the properties.
Groovy
Change the Workspace
This script should be used as the load script if you want to change the workspace before loading your project.
Groovy
File workspaceFile = new File (project.context.expand('${#Env#USERPROFILE}') + "/RepoFolder/WorkspaceFile.xml")
currentWorkspace.switchWorkspace(workspaceFile)
Set the Resource Root
If your project files are stored in a network location, you can make sure ReadyAPI uses the correct resource root.
Groovy