Monday, June 28, 2010

Special Syntax for execute VBScript statements in Java

When we want to execute a vbscript statement from Java, we normally pass in the string that contain the vbscript to the QTP.exec function.

For example
QTP.exec("print(\"hello QTP\")");

this statement will print "Hello QTP" to QTP's console.
Notice that we need to escape all double quotes inside
this statement. This will make the vbscript very hard
to read. There's another way we can execute a vbscript
code in java without the need to escape the double quote.
So instead of write the code like above we write this
QTP.exec(/*print("hello QTP")*/);
Notice that we don't need to escape any double quote
in this VB code. Thus our VB code are more readable.


4 comments:

  1. Hi,
    Could you please tell where we do get the JAVA API, through which calls could be made to QTP ?

    ReplyDelete
    Replies
    1. i.e. qtpcommandserver.client.QTP ?

      Delete
    2. Nimit did u got QTP jar (JAVA API)??

      Delete