If...Then...Else Statement

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

The If...Then...Else statement instructs OpenText Functional Testing to perform a statement or a series of statements based on specified conditions. If a condition is not fulfilled, the next Elseif condition or Else statement is examined. It has the following syntax:

If condition1 Then
	statement
ElseIf condition2 Then
	statement
Else
	statement
End If

Item

Description

condition

Condition to be fulfilled.

statement

Statement to be perform.

Example: In the following example, if the price of a product is greater than $2,000, OpenText Functional Testing closes the browser:

Price = Browser("Advantage Shopping").Page("Advantage Shopping").WebElement("$1,279.00").GetTOProperty("innertext")
If Price > 2000 Then
	Browser("Advantage Shopping").Close
Else 
	Browser("Advantage Shopping").Page("Advantage Shopping").WebElement("$1,279.00").Click
End If

The following example uses If, ElseIf, and Else statements to check whether a value is equal to 1, 2, or a different value:

value = 2
If value = 1 Then
    msgbox "one"
ElseIf value = 2 Then
    msgbox "two"
Else
    msgbox "not one or two"
End If

Tip: Use the Edit > Code Snippet > If...Then menu command to automatically insert an If...Then statement into your test.