Modifying Properties on Saving and Loading Projects

Applies to ReadyAPI 3.56, last modified on November 25, 2024

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.

  1. Right-click your project and select Project Settings.

  2. 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:

You can use this script as the load or save script depending on when you need to modify the properties.

Groovy

project.setPropertyValue("MyProperty", "New Value")

This script should be used as the load script if you want to change the workspace before loading your project.

Groovy

def currentWorkspace = project.getWorkspace()
File workspaceFile = new File (project.context.expand('${#Env#USERPROFILE}') + "/RepoFolder/WorkspaceFile.xml")
currentWorkspace.switchWorkspace(workspaceFile)

If your project files are stored in a network location, you can make sure ReadyAPI uses the correct resource root.

Groovy

project.resourceRoot = "\\\\SharedFolder\\Resources"

See Also

Best Practices

Highlight search results