Creating Reusable Component Using Keywords

A reusable component contains pre-defined steps or actions that can be used across multiple test cases. By calling a reusable component, you can efficiently integrate repeatable steps into any relevant test case. This accelerates the test case creation process and eliminates the need to recreate the same set of steps in every test case.

For example, for testing various workflows of an e-commerce web application, a reusable component containing steps to sign in to the web application can be called across its test cases. This saves time by eliminating the need to recreate the steps to sign in to the web application in each test case.

In this article, we will look into the process of creating a reusable component using keywords. We will create a reusable component using Opkey keywords to log in to a demo CRM application.

1. Hover over the Automate section in the left panel and select Reusable Component icon from the available options. 


2. Click on the Create Reusable Component icon at the top and select Automated Reusable Component.

3. In the Create Reusable Component window on the right, 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.  Click on Click to edit as shown below to add input data to this step. In this step, we will add the browser name as input data.

5. You can also add input data by hovering over the step and clicking the Set data icon.

6. Another option to open the input data window is to click on the three dots icon on the right of Set Data icon and select the Set input data option. You can also delete a step by selecting the Delete option from this window.

7. An Edit data of step window will open on the left. You can add the input or output data for a keyword in their respective tabs by clicking on the data fields in their parameters. Once all data is added, close this window by clicking on the X icon at the top-left corner.

8. 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 the password, and ClickButton with object name as Sign in for steps 2, 3, and 4 respectively.

9. After adding the steps, click the Save button at the top-right corner.

10. 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 show a negative execution result for 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.


3. Search the reusable component created earlier and select to add it to the step.

Note: You cannot call a reusable component in its own step. 

4. Your reusable component is added to the test case.

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.

To learn more about how to use keywords in testing, you can visit Opkey University and enroll in our Opkey series course.

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