Home arrow FAQ arrow Q1 Frequently Asked Questions arrow Debugging And Running Scripts
Oct 23, 2017 at 05:43 PM
Home
Products
Order
Contact Us
Privacy
Q1
Overview
Download
FAQ
License
Requirements
Debugging And Running Scripts

Q1 automated scripts can be developed in any language supported by the Windows Scripting framework, so you can choose whichever suits your needs best. You will find JScript and VBScript installed on any of the supported Windows systems, but you can also download and install 3rd party script language engines. This gives you a great amount of flexibility and saves you from having to learn a new language to develop your tests.

NOTE: always try a demo or evaluation version of a 3rd party script engine before purchasing it. Some vendors implement only a minimal set of functionality which is not enough for running under Q1.

Syntax Extension

The following syntax is also supported by scripts run under the Q1 IDE:

#include "<filename>"

where filename is the path and name of a file to be included. When specifying paths please use only forward slashes ('/'). Paths can be either absolute or relative to the location of the main file (the file which contains the #include directive). The included file must use the same language as the main file. Multiple #include directives can be used.

NOTE: Although the inclusion directives can appear anywhere in the file they will always be processed first, meaning that files can only be included at the beginning of the main file.

The #language directive allows you to specify the which language engine to be used for executing the script. It can appear only in the main script file, it's an error to specify it in included files. If the #language directive is omitted, Q1 will try to determine the language of the script based on the file extension (.js for JScript or .vbs for VBScript). The syntax is:

#language progid|{clsid}

where you can specify either the progid of the script language (for example JScript) or its clsid (example {f414c260-6ac0-11cf-b6d1-00aa00bbbb58})

Root Objects

The framework exposes two helper objects at the root of the script namespace:

Env object: contains methods which allow the script to report errors and informational messages.

Sync object: performs automatic synchronization with external objects and allows asynchronous execution of portions of code.

Debugging

To execute a script just click the Go button on the toolbar, or press F5. Q1 will try to execute whatever script is in the active window. Errors and other messages will be reported in the Results window. A script executed this way is under the control of the debugger, so it can be stopped (using the Break button or by setting a breakpoint) and executed step-by-step.

Breakpoints can be set by using the Toggle Breakpoint button on the toolbar, or by pressing F9 on the current line. You can use the checkboxes in the Breakpoints window to enable/disable breakpoints. If a breakpoint has been set on a line which does not have any script associated with it, it will be moved to the nearest valid line.

When the script is stopped at a breakpoint you can use the Step Into (F11) and Step Over (F10) commands to execute the script step-by-step. The Step Over command will execute a function call as a single block, stopping after the function has returned. Step Into will trace into each function call, stopping after every line of script.

When the script is stopped the Variables window will display the local variables in the current context (for example the local variables of the current function). Double-click or press Enter on a variable to edit its value. Caution: due to the flexibility of script syntax you can implicitly change the type of a variable. For example if variable 'a' is an object and you assign it the value '5' then 'a' will become an integer and the object it pointed to will be destroyed.

The Call Stack window will display the stack trace; double-clicking on a different stack frame will display the local variables of the parent functions.

In the Watch window you can check the values of variables and you can evaluate script expressions. Example of valid expressions:

  • listbox.count (where listbox is a listbox wrapper object) will return the number of items in the listbox
  • app.mshtml.title will return the title of the HTML document
  • Env.LogInfo("test") even if this is a function call which does not return anything it will still be evaluated and the string 'test' will appear in the Results window.

 

Command-Line Mode

Scripts will typically be run under Q1's graphical user interface, however if the tests need to be run from a batch file or as part of a larger test Q1 also provides a command-line mode with the following syntax:

q1.exe filename [> report.txt]

where filename is the name of the test script's main file. All messages logged using the Env object will be written to the standard output, which can be redirected to a text file. Q1.exe will return with exit code 0 if the script has executed OK, or it will return the number of errors reported by the script.

 

Copyright (C) 2002-2009 Lightweight Technologies LLC. All rights reserved. Read our Privacy Policy