Import Custom Code Snippets
    • Dark
      Light

    Import Custom Code Snippets

    • Dark
      Light

    Article summary

    This guide will walk you through the process of importing custom code snippets (classes) and automation assets into Test Modeller, enabling you to build models and generate automated test cases in Java. This is particularly useful when your code lacks inherent backlinks to other Page Objects or Identifiers within Test Modeller. 

    Use Case Scenarios

    Custom code imports are ideal for tasks such as:

    • Asserting PDF files
    • Interacting with complex UI components
    • Connecting to back-end data sources

    Overview of the Process

    When importing custom code into Test Modeller, the process can be streamlined by directly adding and disabling custom code through the New Function pane. This avoids the complexities of updating Page Objects and re-uploading code, making the workflow more efficient and easier to maintain.

    Step 1: Importing Custom Code (Class) as a Zip File

    Prepare Your Code: Ensure your custom code (e.g., for various actions like interacting with a specific UI component) is packaged in a ZIP file.

    Import the Code:

    • Navigate to the main menu and select Explorer.
    • Click the Import button.
    • From the dropdown, select Page Object.
    • Browse and locate your ZIP file, then import it into Test Modeller.

    Verify the Import:

    • After importing, go to Explorer.
    • Locate the newly imported module.
    • Review the file path and listed functions/parameters.
    • Click on any function to edit it. If the Function Type is listed as "Abstract," it means there is no inherent link back to the original code, which allows flexibility in overlaying these attributes across multiple models.

    Step 2: Overlaying New Functions on the Model Canvas

    Create a New Model:

    • Click on New Model to open a new canvas.

    Import and Place Functions:

    • Use the Project Explorer pane to navigate to the newly imported assets.
    • Place a Start node on the canvas and select it.
    • Import relevant functions by selecting them from the Project Explorer pane and clicking Import.

    The imported automation functionality is now represented in your model flow.

    Step 3: Modifying and Re-Uploading Code

    Modify the Original Code:

    • If needed, modify the original Java code outside of Test Modeller. For example, you might rename the GoToURL function to SolrSearchPage or delete an obsolete function like EnterQuery.

    Re-Zip and Re-Upload:

    • After making your changes, re-zip the code and re-upload it into Test Modeller.

    Synchronization:

    • Test Modeller’s synchronization engine will recognize patterns with the same name and structure, merging re-uploads as necessary.

    Step 4: Updating Automation References

    Identify Required Updates:

    • The model will indicate if any objects require your attention (e.g., if they no longer exist in the code).

    Validate and Edit:

    • Click the Validate icon to see which nodes need attention.
    • Use the Automation icon, then click the cog and choose Edit to update references or relocate functions.

    Step 5: Managing Custom Code in Test Modeller

    Add New Custom Functions:

    • Go to Add New Function.
    • From the Function Type dropdown, select Custom Code.
    • In the Custom Code tab, add your custom code directly into Test Modeller.

    Summary

    By following these steps, you can seamlessly integrate custom Java code snippets and automation assets into Test Modeller, enhancing your testing framework's capabilities without the complications of manual updates and synchronization.