Forum Discussion

paramveer's avatar
paramveer
Contributor
13 years ago

Error while executing "Execute" method in test complete.


 



 





Hi



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

Param




 


  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi,



    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