All script editors present in ReadyAPI are usually available at the bottom of the corresponding object’s editor.
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 editor can have one of the following options or both:
|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 editor menu includes the following commands:
|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 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).
You can use property expansions in your code to create objects holding data of other test steps:
Right-click in the editor or click Edit and select Get Data.
Browse the ensuing Get Data dialog to the object or property you need.
Name the created variable.
ReadyAPI will define the variable and create a property expansion to fill it:
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.|
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:
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.