Comments (image map) Parameters (image map) Parenthesis (image map) Calculations (image map) Variables (image map)

Parentheses

Relevant for: GUI actions, scripted GUI components, and function libraries

When programming in VBScript, it is important that you follow the rules for using or not using parentheses () in your statements. You must use parentheses around method arguments if you are calling a method that returns a value and you are using the return value.

For example, use parentheses around method arguments if you are returning a value to a variable, if you are using the method in an If statement, or if you are using the Call keyword to call an action or function. When working with actions, you also need to add parentheses around the name of a checkpoint if you want to retrieve its return value.

Tip: If you receive an Expected end of statement error message when running a step, it may indicate that you need to add parentheses around the arguments of the step's method.

Example: Following are several examples showing when to use or not use parentheses around the method arguments.

Parentheses required when:

  • The method returns a value to a variable:

    Set webelementobj = Browser("Advantage Shopping").Page("Advantage Shopping").WebTable("PRODUCT NAME").ChildItem(2, 2, "WebElement", 0)
    webelementobj.Click
  • Call is being used:

    Call RunAction("BookFlight", oneIteration)

    or

    Call MyFunction("Hello World")
    ...
    ...
  • The method is used in an If statement:

    If Browser("index").Page("index").Link("All kinds of").WaitProperty("attribute/readyState", "complete", 4)
    Then 
        Browser("index").Page("index").Link("All kinds of").Click
    End If 
  • The method returns the value of the checkpoint:

    a = Browser("MyBrowser").Page("MyPage").Check(CheckPoint("MyProperty"))

Parentheses not required when:

The method does not return a value:

Browser("Advantage Shopping").Page("Advantage Shopping").WebTable("PRODUCT NAME").Click 2,2