---
title: "Import Custom Code Snippets"
slug: "import-custom-code-snippets"
description: "Learn how to import Custom Code Snippets and Automation assets into Test Modeller."
tags: ["Test Modeller", "Feature Overviews"]
updated: 2024-09-27T14:49:05Z
published: 2024-09-27T14:49:05Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://knowledge.curiositysoftware.ie/llms.txt
> Use this file to discover all available pages before exploring further.

# Import Custom Code Snippets

This guide will walk you through the process of importing custom code snippets (classes) and automation assets into Quality 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 Quality Modeller.

[Embedded content](https://www.youtube.com/embed/GT8csG-kzNo?&amp;wmode=opaque&amp;rel=0)

### 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 Quality 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 Quality 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 Quality 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 Quality Modeller.

**Synchronization**:

- Quality 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 Quality 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 Quality Modeller.

### Summary

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

## Related

- [Quality Modeller 101](/test-modeller-101.md)
- [Automating Tests](/automating-and-executing-tests-in-test-modeller.md)
