Wednesday, September 10, 2008

QTP Syntax Error

QTP checks for the syntax error when you switch from Expert View to Keyword View.


Syntax can also be checked for the current document at any time by clicking the Check Syntax button, or by choosing Tools > Check Syntax (CTRL+F7).

If a test is open, the syntax of all the actions is checked and on the other hand if a function library is open, the syntax of the function library script is checked.

The Check Syntax button is relevant for only function libraries (and QTP tests), and not for components. QTP checks only the associated function libraries that can be accessed. For example, if an associated function library is stored in a Quality Center project to which you are not currently connected, its syntax will not be checked.

The Information pane will list the syntax errors found in the selected document. You can click on an item in the list to locate the syntax error and correct it.

I opened this library (above) and clicked Tools->Check Syntax and found two errors:
A missing ")" in line 2 and
A missing "Function" in line 5.

You can also double click on the error in the Information pane and it will take the cursor to that error in the test/library.

The same is shown for a test below which has a missing “if” in the End if statement.