List of keywords - Control Flow Construct Keywords

To learn how to use Control Flow Construct keywords in Opkey, you can read Using Control Flow Construct Keywords - New UI and Using Control FlowKeywords - Opkey Classic. Now, let's go through the list of Web keywords and their utility.

 

Condition Keywords

(a). If

This keyword is employed for implementing conditional logic in test cases, particularly useful for creating test flows where the sequence of test steps depends on specific conditions. 


Go to your test case and click on the '+' button to add the Control Flow Construct Keyword. Select If under Control Flow Construct Keyword.




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 a maximum of 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

In a scenario where you need to compare the output of the previous step, the "If" statement checks the specified condition. If true, actions within the first block are executed; otherwise, actions within the "Else" block are executed. 

(b). Else

The "Else" keyword specifies actions to be executed when the preceding "If" condition is not met and is always used alongside the “If” keyword. It does not take any object or data input arguments. 

Go to your test case and click on the '+' button to add the Control Flow Construct Keyword. Select Else under Control Flow Construct Keyword.




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 display anything when the keyword is not executed


Example

In a test flow, when the "If" condition is not satisfied, the "Else" loop is executed, creating a corresponding message. You can use the “else” keyword in this scenario as follows: 



(c). EndIf

"End If" concludes a block of actions initiated by an "If" statement, ensuring proper execution termination when the specified condition is true. It is essential for closing the "If" block. 

Go to your test case and click on the '+' button to add the Control Flow Construct Keyword. Select Else under Control Flow Construct Keyword.



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.



NoteIt's crucial to incorporate the "End If" keyword when using the If statement to ensure the correct structuring and termination of the conditional block.   

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 the “EndIf” keyword can be used as shown below:



The actions within the block execute only if the specified condition after the "If" keyword is true. The "End If" keyword marks the end of this conditional block.  

3. Iteration Keywords

(a). For Loop


The "For" keyword is used to iterate or repeat actions for a specified number of iterations, always paired with the "Next" keyword and taking the number of iterations as input. 

Go to your test case and click on the '+' button to add the Control Flow Construct Keyword. Select For under Control Flow Construct Keyword.



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 display anything when the keyword is not executed



Example

In the given example, the "For" loop is utilized to iterate through login steps for a specific number of repetitions. The loop is controlled by the "Next" keyword and the specified number of iterations provided as input. 


For

Number of iterations completed

5


(b). Next Loop

This keyword, executed with the "for" keyword, concludes the iteration in a "for" loop. It does not require any object or data input arguments. 

Go to your test case and click on the '+' button to add the Control Flow Construct Keyword. Select Next under Control Flow Construct Keyword.



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 display anything when the keyword is not executed



Example

Consider a test flow where logging in on a web page needs to be done 5 times. Instead of employing the login step keyword repetitively, you can utilize a "for" loop with "Next" as illustrated below: 

(c). Exit Loop

This keyword facilitates breaking out of a for-loop and supports breaking out of multi-level nested loops. It is commonly employed when an exit is required from one of the loops within multiple nested loops. 

Go to your test case and click on the '+' button to add the Control Flow Construct Keyword. Select ExitLoop under Control Flow Construct Keyword.




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, its value is Null=0=1; all 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 the “ExitLoop” keyword can be used as shown below:


ExitLoop

levels

2


4. Obstruction Keywords

(a). PauseExecution

Utilized to temporarily halt ongoing execution, this keyword is primarily employed when you wish to pause execution after specific test steps. It is applicable exclusively in the Debug Mode of test execution. 

Go to your test case and click on the '+' button to add the Control Flow Construct Keyword. Select PauseExecution under Control Flow Construct Keyword.


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

In a test flow scenario where a user has logged into a website and desires to pause the execution, the "pause execution" keyword can be employed, as depicted in the screenshot below: 


(b). Sleep

This keyword serves as a static sleep, pausing execution for a specified duration in seconds. It accepts the time duration in seconds as data input arguments. 

Go to your test case and click on the '+' button to add the Control Flow Construct Keyword. Select Sleep under Control Flow Construct Keyword.



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

To introduce a pause after opening a browser, utilize the "Sleep" keyword as demonstrated below: 


(c). StopExecution

Employed to halt the ongoing execution, the final pass/fail status is determined by the steps executed until this point is reached. 

Go to your test case and click on the '+' button to add the Control Flow Construct Keyword. Select Stop Execution under Control Flow Construct Keyword.



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

In a test flow where the user has logged into a website and wishes to terminate the execution, the "stop execution" keyword can be utilized, as depicted below: 


StopExecution

Reason

Simply wanted to test the login process



Common Error conditions

To read about the error conditions of the above keywords, click Here


Explore more Opkey features by clicking Here.



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article