A reusable component is a pre-defined set of test steps or actions that can be used with multiple test cases. After creating such a component with specific steps, it can be utilized in any test case requiring those actions. This accelerates the creation of new test cases by eliminating the need to duplicate steps.
Now, let's look into the process of creating a reusable component using keywords. We will create a component to log in to a demo CRM application.
3. In the Create Reusable Component window on the left side, you can input a Name, set Priority, Assign a user, provide a Description, and attach files by scrolling down. You can add spreadsheets, images, videos, etc. to the component. Finally, click Create when finished.
4. Click 'Add Step' at the top and search the action keyword in the search bar of the Step. Matching keywords corresponding to the searched text will appear in a list; choose the one you want to add by clicking on it.
For example, we have selected OpenBrowser keyword in the first step.
4. Similarly, add steps by clicking on the Add Step and add relevant keywords and input data to a step by clicking on Click to edit as shown below.
5. You can also add input data by hovering over the step and selecting the Set data option. Another option to open the input data window is to click on the three dots icon and select the Set input data option.
6. An Edit data of step window will open on the left. You can add the respective input or output data by clicking on the parameter. Once all data is added, close this window by clicking on the X icon at the top-left corner.
7. Follow the same process to add more steps with relevant data to your reusable component. We have added three more steps with keywords TypeTextinTextArea with input data for username, TypeSecureText with input data for password, and ClickButton with object name as Sign in for steps 2, 3, and 4 respectively.
8. After adding the steps, click the Save button at the top-right corner and click Run to execute the reusable component to sign into a CRM application.
9. There are a few advanced settings that can be used to customize test execution. Click on the Settings Icon and select any option before execution.
ContinueOnError: Check this checkbox if you want execution to continue even if an error occurs within a step.
WantSnapshot: Check this checkbox if you want snapshots of all steps during execution.
IsNegative: If you check this checkbox, it will change the execution result of the step. It will show a passed step as failed and a failed step as passed. This is useful in negative testing.
Using a Reusable Component in a Test Case
1. Click on the Tests tab in the Automate section. Select a test case from the list where you want to add the reusable component.
2. Click on Add Step at the top and click on the drop-down in the right-hand corner of the test step. Select the Reusable Component option and choose the reusable component from the list to be added.
Note: You cannot call the same Reusable Component file within itself.
3. You can also perform different actions over the Reusable Component by right-clicking over any selected test step. These actions are Copy, Paste, Add Step, Delete, Move Up, Move Down, Set to Run, Skip From Run, and Record.
You've reached the end of this article and are now well-prepared to create a reusable test component using keywords.
Ready to dive deeper? Check out the next article: Creating a Global Data Repository.
Explore, experiment, and achieve your testing goals on Opkey!
Was this article helpful?
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
We appreciate your effort and will try to fix the article