How do I skip specific set of lines of code during execution
This example demonstrates how to skip a specific set of lines of code during execution using the "skipNext" command.
In the solution shown below, you will see that the "select" command for selecting an option for "Does Employer offer Health Insurance" dropdown is skipped in HICC based on the environment using the "skipNext" command within the "if-endIf" construct.
Note: You can use store or storeXXX command to define the value (string or boolean) of the variable. The notation to reuse the value of the variable in Worksoft SaaS is ${<Variable Name>}.
Solution:
# | Command | Target | Value |
---|---|---|---|
Start the "If" construct. If the environment is Production, skip the selection of option in "Does Employer offer Health Insurance" dropdown | |||
1 | If |
"${<Variable Name>}"=="Production" | |
Skipping the next 2 instructions |
|||
2 | skipNext |
2 |
|
End of "if" block | |||
3 | endIf | ||
Select an option from Does Employer offer Health Insurance dropdown | |||
4 | select | id="dpl_employerInsuranceDropdown" |
label=Yes |
Click on Calculate Button | |||
5 | click | id="btn_calculateControls" |
Tips, Tricks, Gotchas & Best Practices:
- The value for the variables can also be driven from a Data-file, System Defined Variable or User Defined Variable.
- In conditions, while comparing numeric values, do not use double quotes("), as it would consider the value as a string.
- As a best practice, it is always advisable to define the variable names without any spaces and if you want to differentiate the words, use underscore or hyphen.