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
Output
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
Output
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
Note: It'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
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
Output
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
(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
Output
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
Output
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
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
Output
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
Output
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
Output
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
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
Feedback sent
We appreciate your effort and will try to fix the article