Creating Reusable Component Using Keywords
  • 04 Feb 2024
  • 3 Minutes to read
  • Dark
    Light

Creating Reusable Component Using Keywords

  • Dark
    Light

Article Summary

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.

For example, for an e-commerce web application, a reusable component can be created to sign-in to the web application.
These components can be created by adding steps automatically or manually. 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.

  1. Hover over the Automate section in the left panel and select Test from the available options.
    1.png

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

  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.
    3.png

  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.png
    5.png

  5. 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.
    6.png

  6. 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.
    7.png

  7. 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.
    8.png

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

  9. 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.

    image.png

  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 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.
      11.png

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.
    image.png

  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.
    13.png

    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.
    14.png

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?
Explore, experiment, and achieve your testing goals on pCloudy!


Was this article helpful?