Script Editor


Contents
1. Script Editor Overview
2. Editing Features
3. Syntax Highlighting
4. Command Wizard
5. Template Wizard
6. Syntax Validation
7. Breakpoints
8. Custom Popup Menus
9. Execution Tracing
10. Execute Selection
11. Step by Step Execution

1. Script Editor Overview

Script editor provides capability to:

2. Editing Features

VNCRobot editor provides editing capabilities common in other text editors:
The editor saves all documents in the UTF-8 encoding. Note that though you should be able to save a text file with any multibyte text, VNCRobot cannot send characters out of ISO 8859-1 to VNC server. It means that you can use national characters of most Western Europe languages (German, Spanish, French, ...) but not Asian, Arabic, East Europian etc. This is a limitation of the RFB protocol.

3. Syntax Highlighting

VNCRobot v1.3 introduces a rich text editor able to highlight the script syntax. Elements of the commands are parsed automatically and they are displayed with configured attributes, i.e. font type and background/foreground color. To configure the editor style open the Preferences window and navigate to the Appearance & Accessibility->Script Editor tree node:

Editor Styles

4. Command Wizard

VNCRobot editor has a new command wizard which allows to select commands comfortably from a list instead of typing them manually. The wizard can be activated by pressing Ctrl+Enter in the editor. When invoked on an empty line, it displays a list of available commands as is shown on the picture below. Commands can be also activated by shortcut keys as is visible in the list below.

Command List

If you type a part of a command and open the wizard, it will match the text against the list and display just applicable commands. If you e.g. type 'ty' and press Ctrl+Enter, the wizard will display just the Type and Typeline commands. This happens also when the wizard list is displayed. If the text you typed is sufficient to identify the command, it is inserted automatically into the script without displaying the list. Try to type e.g. 'scr' and press Ctrl+Enter to insert a Screenshot command into the script.

Pressing of Ctrl+Enter in a line which already contains a valid command displays a list of supported command parameters. An example of the Connect command parameters is shown on the picture below. If you select on in the list, it will be inserted at the end of the line together with a hint on what the parameter value should be like. Note that the wizard does not validate the command in any way and it also doesn't check which parameters the line already contains.

Command List Parameters

To modify the shortcut key (Ctrl+Enter) open the Preferences window and navigate to Appearance & Accessibility -> Script Editor.

5. Template Wizard

Code templates are predefined pieces of code. To insert a code template press Ctrl+I or select "Insert a Template" in the Command Wizard.

Template Wizard

For example, to open the Windows Explorer one usually presses Windows+e on the keyboard and waits until the explorer opens. To insert such an action into your automated test script you can simply select the template highlighted in the list above.

Each code template has a short key which allows quicker selection. To insert the Windows Explorer template without displaying the wizard type 'winexp' into a new line of your editor and press Ctrl+I.

To modify the shortcut key (Ctrl+I) open the Preferences window and navigate to Appearance & Accessibility -> Script Editor.

The Template Wizard was introduced in VNCRobot 1.3.1. Note that the template list is currently fixed and can't be customized. A GUI to edit the list will be provided in one of the next 1.3.x releases.

6. Syntax Validation

Script editor is capable of validating syntax of your test script. It means that it checks whether your commands have correct syntax and highlights the incorrect commands as is shown on the following picture. If you place your mouse pointer above the invalid line, a tool tip message with the error description should appear.

Invalid command in an editor

To configure color of the highlight open the Preferences window and navigate to the Appearance->Script Editor tree node.

There are two points when validation is performed:
Automatic Validation
Whenever you modify a script, automatic validation is run after a certain period of idle time. This might cause delays by large scripts. To enable or disable this feature and configure the timeout open the Preferences window and navigate to the Scripting tree node. This feature is by default on.

Pre-execution Validation
When you select Run or Run Selection to execute a script or its part, a validation is performed. If there are errors, a warning message gets displayed. There are options to execute the script anyway (Yes) and to cancel the execution (No):

7. Breakpoints

Breakpoints let you stop execution of a script on certain lines. Once a breakpoint is reached, the script gets paused and won't resume until you deselect the Pause menu item or toolbar button.

To define a breakpoint, click onto the grey column on the left side of the script editor. The command line turns red and a red globe icon gets displayed in the column. Eventually left click on the column to open the breakpoint popup menu and select Add Breakpoint. You can remove breakpoints in a similar way. The menu also provides a way to remove all breakpoints in the editor. See the following picture which shows activated popup menu for an already existing breakpoint.

Breakpoint popup menu

To configure breakpoint color open the Preferences window and navigate to the Appearance & Accessibility->Script Editor tree node.

8. Custom Popup Menus

Script editors provide a way to customize the editor popup menu. This is often used by commads to provide quick access to command features, help and configuration. To open a custom popup menu for a command right click onto the command in the editor. The following picture shows a custom popup menu for the Press command which includes:
Custom editor popup menu for the Press command

Popup menus may also contain dynamic items which are available only under specific conditions. If you for example execute a Wait command or Waitfor together with the timeout parameter, the menu contains an item labeled Continue which lets you to bypass the timeout and resume the execution immediately.

The menu can be also activated by pressing Ctrl+Shift+Enter. To modify this shortcut key open the Preferences window and navigate to Appearance & Accessibility -> Script Editor.

9. Execution Tracing

When a script is being executed, VNCRobot switches among editors and scrolls the editor view to show the executed line. This feature enables user to see the execution progress and currently executed command. The following picture shows an example of an executed line.

Executed command line

This feature can be controlled by two flags:
To configure color of the executed line open the Preferences window and navigate to the Appearance->Script Editor tree node.

10. Execute Selection

If you want to execute just a part of your script, you may select (highlight) the lines you want to execute and select the Execute Selection menu item to start the execution. Note that the commands do not have to be highlighted completely. Even if you select just a single character in the command, VNCRobot executes the whole line. The following picture shows execution of two selected command lines.

Run selected commands

Note two important features of partial executions.

11. Step By Step Execution

There's a Step By Step Execution menu item and toolbar button which allows you to execute just one line of code at a time. The following rules apply: