Forum Discussion

paramveer's avatar
13 years ago

Error while executing "Execute" method in test complete.




objectFullNameString is a object having fullname of object.



Execute objectFullNameString &"."& "CheckItem("&"""|Sectors|LZONE Classification|Banks|Axis Bank Ltd"""&", True)"

When we are executing the Execute Method system is giving following error.

"Microsoft VBScript compilation error."

"Cannot use parentheses when calling a Sub"

Please suggest what to do in this case

Thanks in advance



1 Reply

  • HKosova's avatar
    SmartBear Alumni (Retired)

    Your string evaluates to something like this:

    In VBScript, if you use parenthesis when calling a subroutine, you must also use the Call keyword. If you don't use the Call keyword, the argument list must NOT be surrounded by parenthesis.

    So, you need to either use the Call keyword:

    or remove parenthesis from the CheckItem method call:

    By the way, a shorter and simpler way to do the same thing is to evaluate only the object itself rather than the whole statement:

    Call Eval(objectFullNameString).CheckItem("|Sectors|LZONE Classification|Banks|Axis Bank Ltd", True)

    ' or

    Eval(objectFullNameString).CheckItem "|Sectors|LZONE Classification|Banks|Axis Bank Ltd", True