Applies to ReadyAPI 3.0, last modified on November 12, 2019

All script editors present in ReadyAPI are usually available at the bottom of the corresponding object’s editor.

The script editor

Click the image to enlarge it.

Depending on the event handler you use, various objects are available in your script. Objects that you can use in your script are in the line above the editor. For details about using ReadyAPI scripting objects, see Script Extensions.

The default scripting language is Groovy. You can change it in the Project Properties panel.

You must restart ReadyAPI for the change to take effect.
The Project Properties panel

The editor can have one of the following options or both:

Option Description
Run Starts the script run.
Edit Opens the editor menu.

Instead of clicking Edit to call the editor menu, you can right-click inside the input box.

The script editor menu

The editor menu includes the following commands:

Command Description
Undo Undoes the previous action.
Redo Redoes the undone action.
Cut Cuts the selected part.
Copy Copies the selected part.
Paste Pastes clipboard contents to the caret position.
Delete Deletes the selected part.
Select All Selects all text in the editor.
Folding Opens or closes folds in the editor.
Find / Replace Opens the Find / Replace dialog that allows you to select finding options and text to replace.
Code Completion Shows available methods and parameters.
Change Color Scheme Changes the colors of the editor by using the selected color scheme.
Go to Line Moves the caret to the specified line.
Show Line Numbers Shows or hides line numbers.

If your script is large, it may not fit into the script editor. Click Panorama View to quickly move to the part of the code you need.

You can also change the font size in the editor by rotating the mouse wheel while holding the Ctrl key (on Windows and Linux) or by sliding two fingers up or down the trackpad while holding the Command key (on macOS).

Using Property Expansions

You can use property expansions in your code to create objects holding data of other test steps:

  1. Right-click in the editor or click Edit and select Get Data.

    The Get Data function

    Click the image to enlarge it.

  2. Browse the ensuing Get Data dialog to the object or property you need.

    The Get Data function

    Click the image to enlarge it.

  3. Name the created variable.

  4. Click OK.

ReadyAPI will define the variable and create a property expansion to fill it:

Groovy

def password = context.expand( '${Test Request – logout#Password}' )

Code Completion

ReadyAPI script editors support code completion for Groovy. As you type code, available methods and parameters will appear in a drop-down list, so you can select them and speed up the code writing.

You can also move the caret to the object, the methods and parameters of which you need to call, and press Ctrl+Space to view the list of available entities.

Code completion also shows methods and parameters from custom Java libraries and JAR libraries located in the /bin/ext and /lib directories.

Note: Code completion cannot show methods and parameters from libraries located in subdirectories of the /lib directory.

Code Validation

By default, ReadyAPI automatically validates the Groovy syntax when running a script and displays a message about syntax errors and their location, if any. Sometimes, this may cause ReadyAPI performance issues. To avoid potential problems, you can disable Groovy syntax checking by using the following line: -Dgroovy.disable.syntax.checking=false.

Code Templates

ReadyAPI offers support for configurable code templates. To activate them, type the corresponding template ID in the editor and press Ctrl+Shift+Space.

You can view and edit code templates on the Code Templates page in ReadyAPI Preferences.

See Also

Code Templates
Script Extensions
Script Libraries
Scripting

Highlight search results