Lesson 13 Topic 1 Features
This article is a part of the Self-paced Learning Series for the Course: First-Hand Experience of Worksoft SaaS.Please refer to the link for more details on the Course.
Introduction of Worksoft SaaS Feature/Concept :: Lesson 13 :: Topic 1
1. Conditional Statements in the Test Scripts
In some cases, you may need the automation testing to support you in performing result-based actions, which means, add a condition and when the condition is not satisfied, it should have the ability to perform an alternate action.
For Example: Let's take a scenario of an e-commerce application, where you want to search for a Product; there are two possibilities here, either the search returns the product in the results or the search returns 0 matching results. In that case, you may want to perform result-based actions like, if the search returns the expected Product, add it to the cart. Else, you may want to end your action.
For requirements like these, Conditional Statements are very useful. You can build automation to Search for a specific product and use Conditional Statements like If-elseif-else-endif to perform result-based actions. Within this Conditional Statement, you will be storing the visibility of an element and performing the actions based on the visibility. If the condition is satisfied, the visibility returns true and you can add the commands to perform the action 'Add it to the cart'. If the condition is not satisfied and the visibility returns false, the command 'Endif' will exit the Test.
Worksoft SaaS allows for nesting of if-endif statements up to 10 levels. However, it is recommended to use a maximum of 3 Conditions while including Conditional Statements in a Test Script, for easy maintenance.
2. Copy Instructions within a Test Script using Keyboard shortcuts
When you want to add some additional commands an existing element, For Example: Adding storetext command to the Order ID in an e-commerce application, we would naturally go to 'add an instruction', however, adding the locators for the element in the Target field would be a strenuous task. In this case, it is easier to copy the instruction by using keyboard shortcuts (Ctrl C + Ctrl V) of the corresponding element because the instruction will have all the locators copied, you can then make the necessary modifications like updating the command field and value field and your additional command is created in a hassle-free way.