1. Home
  2. Opkey Help
  3. 25. Opkey Keyword Documentation
  4. 25.4 Control Flow Construct Keywords

25.4 Control Flow Construct Keywords

Comment Keywords

Comment

This keyword is used to write comments for any Test flow or Test scenarios. This keyword is mostly used in situations where you want to mention any explanations for testers or users regarding the testing scenarios. Comments are always user defined.

Input Arguments

Object Input Arguments

Required?

Description

Object

No

This keyword doesn’t take any object input argument.

Data Input Arguments

Required?

Description

Data

No

This keyword doesn’t take any data input argument.

Example

If you have created a Test flow and you want to mention comment for it, then you can use the Comment keyword as follows:

# Comment

This test flow is created to test the proper flow of execution of login process.

 

Common Error conditions

There are no error conditions for this keyword.

Condition Keywords

Else

This keyword is used to provide an alternative scenario to be executed; when IF condition fails. It is always executed along with “If” keyword. It does not take any Object or data  input arguments.

Input Arguments

Object Input Arguments

Required?

Description

Object

No

This keyword doesn’t take any object input argument.

Data Input Arguments

Required?

Description

Data

No

This keyword doesn’t take any data input argument.

Output

True

If the keyword passes successfully

False

It does not displays any thing when the keyword is not executed

Example

Let us consider a test flow where you want to verify the If condition. If the If condition is not satisfied then it comes to the Else loop and creates corresponding message. In this case you can use “else” keyword as follows:

Common Error conditions

Scenarios

Error Message

Debug Information

When Else keyword is used without using If

Dangling Else (-9901500)

DESCRIPTION:

An ELSE keyword is not properly matched to an IF/ENDIF keyword pair. Every ELSE keyword must be properly surrounded by IF and ENDIF keywords.

An ELSE keyword is not properly matched to an IF/ENDIF keyword pair. Every ELSE keyword must be properly surrounded by IF and ENDIF keywords.

EndIf

This keyword is used to declare End of If block in your test case. This keyword is always used with If statement.

Input Arguments

Object Input Arguments

Required?

Description

Object

No

This keyword doesn’t take any object input argument.

Data Input Arguments

Required?

Description

Data

No

This keyword doesn’t take any data input argument.

Note: It is mandatory to use If statement while using EndIf.

Output

True

If the keyword passes successfully

It does not display anything when the keyword is not executed

Example

Let us consider a test flow where you want to end the If loop then “EndIf” keyword can be used as shown below:

To declare End of If block in your test case you need to use EndIf statement.

Common Error conditions

Scenarios

Error Message

Debug Information

When EndIf Keyword is used without using If

Endif Without If (-9901400)

DESCRIPTION:

An ENDIF keyword is not properly matched to an IF keyword. Every ENDIF keyword must be properly matched with its conjugate IF and vice versa. Also the ENDIF keyword must appear after the IF keyword

An ENDIF keyword is not properly matched to an IF keyword. Every ENDIF keyword must be properly matched with its conjugate IF and vice versa. Also the ENDIF keyword must appear after the IF keyword

If

This keyword is used to use conditional logic in your test case. This keyword is mostly used in situations where you want make a test flow in which the Test steps are based on some conditions.

Input Arguments

Object Input Arguments

Required?

Description

Object

No

This keyword doesn’t take any object input argument.

Data Input Arguments

Required?

Description

Operands

Yes

Specify  the operands to be compared.

Note: You can specify maximum two operands for a single condition.

Operator Yes It is a dropdown from where you can select the conditional/relational (And/OR) operator.

Output

 

True

If the condition is true

False

If the condition is false  or the keyword fails

Example

Let us consider a test flow where you have to compare the output of the previous step:

Common Error conditions

Scenarios

Error Message

Debug Information

When If Keyword is used without using EndIf

If Without Endif (-9901300)

DESCRIPTION:

An IF keyword is not properly matched to an ENDIF keyword. Every IF keyword must be properly matched with its conjugate ENDIF and vice versa. Also the ENDIF keyword must appear after the IF keyword.

An IF keyword is not properly matched to an ENDIF keyword. Every IF keyword must be properly matched with its conjugate ENDIF and vice versa. Also the ENDIF keyword must appear after the IF keyword

When  Data Input Arguments are not provided

Argument Data Missing (-13200)

 

DESCRIPTION:

A step could not be executed because one or more of the arguments have not been provided a value. Of all the arguments a keyword accepts, some arguments might be compulsory. As opposed to the non-compulsory ones, the compulsory argument must be provided some data. The data may be provided through one of many sources like statically entering, output of a previous step, a global variable etc; but it must not be left blank.

All the expressions cannot be blank

Iteration Keywords

ExitLoop

This keyword is breaks out of For-Loop.It Supports breaking out of multi level nested loops. This keyword is mostly used in situations where you need to take exit from one of the loop among several nested for loops.

Input Arguments

Object Input Arguments

Required?

Description

Object

No

This keyword doesn’t take any object input argument.

Data Input Arguments

Required?

Description

levels

Yes

Specify the number of levels to break out. By default, it’s value is Null=0=1; all the three means breaking out of the current for loop.

Output

 

True

If the keyword passes successfully

False

If an error is there

Example

Let us consider a test flow where you want to exit from the For loop after 3 iterations then “ExitLoop” keyword can be used as shown below:

ExitLoop

 

levels

1

Common Error conditions

Scenarios

Error Message

Debug Information

When invalid data input argument is provided.

Levels : -2

Argument Data Invalid (-13300)

DESCRIPTION:

The data value for one or more input arguments was not what was expected. This might happen when the input is expected in a specific format or should be chosen from a predefined set of values. Check for spell errors and capsing.

Number of levels cannot be less than 1. Given : -2

For

This keyword is used for looping or repeating a set of keywords for some specific number of iterations (repetitions). It is always executed along with “Next” keyword. It takes number of “Iterations” as the data input arguments.

Input Arguments

Object Input Arguments

Required?

Description

Object

No

This keyword doesn’t take any object input argument.

Data Input Arguments

Required?

Description

Iterations

Yes

Specify the number of times( repetitions) for which you want to repeat the Test steps.

Output

 

Number of iterations completed

If the keyword passes successfully

It does not displays any thing when the keyword is not executed

Example

Let us consider a test flow where you have to iterate login steps number of times then you can create a for loop by using “for” keyword as follows:

For

Number of iterations completed

5

Common Error conditions

Scenarios

Error Message

Debug Information

When for keyword is used without using Next

For Without Next (-9901100)

DESCRIPTION:

A FOR keyword is not properly matched to a NEXT keyword. Every FOR keyword must be properly matched with its conjugate NEXT and vice versa. Also the NEXT keyword must appear after the FOR keyword.

A FOR keyword is not properly matched to a NEXT keyword. Every FOR keyword must be properly matched with its conjugate NEXT and vice versa. Also the NEXT keyword must appear after the FOR keyword.

Next

This keyword is used to end the “for” loop iteration. It is always executed along with “For” keyword. It does not take any Object or data  input arguments.

Input Arguments

Object Input Arguments

Required?

Description

Object

No

This keyword doesn’t take any object input argument.

Data Input Arguments

Required?

Description

Data

No

This keyword doesn’t take any data input argument.

Output

 

True

If the keyword passes successfully

It does not displays any thing when the keyword is not executed

Example

Let us consider a test flow where you have to login on a web page 5 times. Then instead of using login step keyword 5 times, you can create a for loop by using “for” keyword along with “Next” as follows:

Common Error conditions

Scenarios

Error Message

Debug Information

When Next keyword is used without using for

Next Without For (-9901200)

 

DESCRIPTION:

A NEXT keyword is not properly matched to a FOR keyword. Every NEXT keyword must be properly matched with its conjugate FOR and vice versa. Also the NEXT keyword must appear after the FOR keyword.

A NEXT keyword is not properly matched to a FOR keyword. Every NEXT keyword must be properly matched with its conjugate FOR and vice versa. Also the NEXT keyword must appear after the FOR keyword.

Obstruction Keywords

PauseExecution

This keyword is used to pause the ongoing execution. This keyword is mostly used in situations where you want to pause the ongoing execution after certain Test Steps. This keyword is used in Debug Mode of test execution only.

 

Input Arguments

Object Input Arguments

Required?

Description

Object

No

This keyword doesn’t take any object input argument.

Data Input Arguments

Required?

Description

Data

No

This keyword doesn’t take any data input argument.

Output

True

If the keyword passes successfully

Example

Let us consider a test flow where the user has logged in to a website and now want to pause the execution then “pause execution” keyword can be used as shown in the screenshot below:

This keyword will pause the ongoing execution and then the execution can be resumed manually.

Common Error conditions

There are no error conditions for this keyword.

Sleep

This keyword is a static sleep and it waits (sleeps) for specified time (sec). This keyword takes seconds as Data input arguments

Input Arguments

Object Input Arguments

Required?

Description

Object

No

This keyword doesn’t take any object input argument.

Data Input Arguments

Required?

Description

Seconds

Yes

This keyword doesn’t take any data input argument.

Output

True

If the keyword passes successfully

Example

If you want to wait for a while after Opening any browser then use “Sleep” keyword as shown below:

Sleep

Seconds

10

Common Error conditions

There are no error conditions for this keyword.

StopExecution

This keyword is used to stops the ongoing execution. The Final PASS/FAIL status would depend on steps executed until this point is reached.

Input Arguments

Object Input Arguments

Required?

Description

Object

No

This keyword doesn’t take any object input argument.

Data Input Arguments

Required?

Description

Reason

No

It is optional to specify the reason why the session is being stopped.

Output

 

True

If the keyword passes successfully

Example

Let us consider a test flow where the user has logged in to a website and now want to stop the execution then “stop execution” keyword can be used as shown below:

StopExecution

Reason

Simply wanted to test the login process

Common Error conditions

There are no error conditions for this keyword.

Was this article helpful to you? Yes No