# Script Builder

Loadium Script Builder is a feature that aims to ease and quicken your load test preparation in terms of scripting.

## Getting Started

There are 2 ways to utilize from Script Builder:

1. [You can create a script from scratch by creating HTTP Requests manually](#requests)
2. [You can import supported files (Swagger, HAR, Loadium Recorder, Postman)](#import)

You can go to Create Page and choose Script Builder to start creating a test.

<figure><img src="/files/eIKhaEpYqwYqB43jXfTq" alt=""><figcaption></figcaption></figure>

## Creating a Script

### Import

Loadium supports four different file types for importing into Script Builder.

Supported file types for import:

* **Postman Collection** – Exported collection of API requests from Postman.
* **HTTP Archive (HAR)** – Captured network traffic in HAR format.
* **Swagger (OpenAPI)** – API definitions in Swagger/OpenAPI specification.
* **Loadium Recorder File** – Files recorded using the Loadium Chrome extension.

<figure><img src="/files/rdbSFheP7N5KHyNQDZlA" alt=""><figcaption></figcaption></figure>

#### Postman

By uploading your Postman collection to the script generator, you can easily organize it and make it ready for load testing. You can upload multiple collections at once.

<div><figure><img src="/files/H2EYCimLT1ugiwyUfRrE" alt="" width="375"><figcaption></figcaption></figure> <figure><img src="/files/4ge58luLABr4ThOJvoUW" alt="" width="375"><figcaption></figcaption></figure></div>

Here is a preview of the script editor screen after the uploading is completed.

<figure><img src="/files/88oMLDbUxBXeH2YveunV" alt=""><figcaption></figcaption></figure>

#### HTTP Archive (HAR)

Similar to Postman, you can easily import your files with the ".har" extension into the script generator.

<figure><img src="/files/lspOPh98J4YzpUFGedf3" alt="" width="375"><figcaption></figcaption></figure>

<figure><img src="/files/YjLQwP7jCIg0o6k3Tvz0" alt=""><figcaption></figcaption></figure>

#### Swagger

Loadium allows you to import your Swagger by uploading your Swagger file or using your Swagger URL.

<figure><img src="/files/Na0vZj1WivKrUgW0Zq7I" alt="" width="375"><figcaption></figcaption></figure>

<div><figure><img src="/files/MUF0brjKiV9qcw9BGKEz" alt="" width="375"><figcaption></figcaption></figure> <figure><img src="/files/nVIcIN9nNpMtT2gaHm4R" alt="" width="375"><figcaption></figcaption></figure></div>

#### Loadium Recorder (Google Chrome Extension)

Allows you to record HTTP requests, URLs, their parameters, and headers while you are browsing the web.

{% tabs %}
{% tab title="Installing the Recorder" %}

#### Installing the Extension

You can find the page for installing the extension to Google Chrome [here](https://chrome.google.com/webstore/detail/loadium-extension/eecaejegccegjjjngokgelmehfkmpico/related).

After installing the extension, remember to pin it from the extension manager.

&#x20;                                                  <img src="/files/-MZGvXcyHGQL5fU09D0t" alt="" data-size="original">

Now you can easily access to Record\&Play.
{% endtab %}

{% tab title="Recorder UI" %}
A quick tour of the extension’s interface.&#x20;

![](/files/-MZGx7uFmZfgae6E2X-B)

You can find the explanation below for each numbered button:

1. These buttons (start button and the big orange button) will **start the recording** session, as you browse, it will add requests to the Collections section. Once the recording is started, you will notice that its icon has changed.

   &#x20;                                             <img src="/files/-MZGzQbqaRfAXzaxJC6V" alt="" data-size="original">&#x20;
2. If you want to **clear the recording**, you can use this button to wipe the collections you previously recorded.
3. You can **download the recording** by using this button, as .json file.
4. Pressing this button will take you to **settings** of recording.

   These settings allows you to filter your recordings. You can define a regex pattern in order to capture specific URL’s. For example entering pattern as “https\://\*.youtube.com/\*” will record URL’s that contains “youtube.com” in it. Furthermore, you can choose to record only the top level requests or additional sub-level requests.
5. This button will **create a new set of collection** next to your previous collection, which the new recordings will be added to this new collection.
6. This button will take you to the **Login Page**, if you’re logged in you will see your email address here.
7. If you’re logged in, clicking this button will take you to **Loadium Record\&Play Page**, then you can start editing your recorded requests, or directly save\&run your test.
   {% endtab %}
   {% endtabs %}

## **Editing Script**

You can start editing your script after you've followed one of the processes:

* Pressing "Create" button,
* Importing via Postman, HAR file, Swagger, or Loadium Recorder..

<figure><img src="/files/pEtjguAY8HkwyjfHgBh0" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Make sure to save your script after making major changes to avoid losing any progress.
{% endhint %}

### **Collections**

Collections allow you to separate the script into smaller pieces, making it easier to work with. Similar to Thread Groups in JMeter, you can add multiple collections to organize different parts of your test scenario independently. You can create collections by clicking "***+ New***" button.

<figure><img src="/files/osXyrEcK8ZB5i3MK7dFo" alt="" width="375"><figcaption></figcaption></figure>

You can add multiple collections if you want. For each collection, you can:

<figure><img src="/files/IEtavPQtTDmYrzPDvwlG" alt="" width="375"><figcaption></figcaption></figure>

* Add a new request which then you can configure its details.

<figure><img src="/files/FGfZ7hKBfqqauc822Z12" alt="" width="375"><figcaption></figcaption></figure>

* Add sleep which adds a delay before the next request. You can enter the delay amount (in milliseconds) as you desire.

<figure><img src="/files/c63fYX5FRgbPMLLi8Ugk" alt="" width="375"><figcaption></figcaption></figure>

* Edit the label of your collection.
* Duplicate the collection.
* Delete the collection if you would like to.

For each request in the collection, you can:

<figure><img src="/files/upb2RHMxvvRmmWvwvgl7" alt="" width="375"><figcaption></figcaption></figure>

* **Edit** the request
* **Duplicate** the request
* **Delete** the request from collection

You can also change the position of requests by gripping them, to change their order or group them in a collection.

### **Requests**

{% tabs %}
{% tab title="Basics" %}

#### **Method Type**

You can set request types as GET, POST, PUT, PATCH, DELETE, and OPTIONS.

#### **Query Params**

You can add query parameters to your request as shown in the picture.

<figure><img src="/files/29xVwaj7xojscfkr35MG" alt=""><figcaption></figcaption></figure>

#### Body

Depending on the method type, you can manage its body to send data with the request.

<figure><img src="/files/RHUaqhL2ZbXLYPCXVOvJ" alt=""><figcaption></figcaption></figure>

#### **Headers**

<figure><img src="/files/P268TXqbqjM80IEZypRf" alt=""><figcaption></figcaption></figure>

You can add a new header or delete the existing ones.

* To remove a header, use the Delete (trash can) icon located at the end of the corresponding row.
* To add a new header, click the "+" button located at the top right, and specify the Key and Value fields.
* To bulk edit request headers, click "Bulk Edit" button at the top right corner.

<figure><img src="/files/9DRfbfmACfkLF5u3oAX2" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Variables" %}
You can create variables that allows you to capture a specific data from a request’s response and store it for using later.

There are 3 ways of expression to capture the data to store it in a variable:

* JSON Path
* Regex
* CSS Selector

<figure><img src="/files/h0oKNDqw8eLYKWFnpPdd" alt=""><figcaption></figcaption></figure>

For each type there are areas to be filled, Variable Name and Expression (Attribute for CSS selector). The referred data will be stored in the variable.

For CSS Selector, there are 2 additional areas that are related to capturing the data.

* The referenced CSS element might have multiple values, attribute is for specifying to which value to restore. Leaving it empty will capture the text value of the element.
* Match number is for choosing one outcome if there are more than one reference. Value “0” is used for random outcome.                                   &#x20;

You can access the created variable’s value with the expression ${variableName}.
{% endtab %}

{% tab title="Assertions" %}
You can make various type of assertions that uses response data to check conditions:

<figure><img src="/files/slDgfim5zNUSmOEL0dBn" alt=""><figcaption></figcaption></figure>

* **HTTP Status Code** assertion, allows you to assert the value of the response code.&#x20;
* **Body** assertion, allows you to assert the body of a response.
* **Headers** assertion, allows you to assert the header of a response
* **JSON Path Value** assertion, allows you to capture a value using a json path expression, then compare it to expected result
* **JSON Path Assertion**, asserts that the given json path expression contains value, is not null.
  {% endtab %}
  {% endtabs %}

## **After Editing**

At the bottom of the page, you will see 2 buttons.

<figure><img src="/files/3Z7W9MJYQxDmO7iyfW8q" alt=""><figcaption></figcaption></figure>

* Clicking either "Save Test" or "Run Test" will redirect you to the Main Settings tab on the New Test page, with your .jmx file uploaded and ready to run.

<figure><img src="/files/sOvktity99183AXebkJV" alt=""><figcaption></figcaption></figure>

* You can also configure your test settings before saving your test by clicking ***Test Settings** tab.*

<figure><img src="/files/VUVJpaBOB1zGBtWn9EWJ" alt=""><figcaption></figcaption></figure>

* You can also download the file as JMX or JSON (Loadium Recorder) file.

<figure><img src="/files/StkwLdG7ERLxOw63VLlx" alt="" width="365"><figcaption></figcaption></figure>

### Global Variables

You can define global variables to be used within requests when necessary. Utilizing this will make it easier when you need to constantly change some values within requests (for example, changing target URL from test environment to production environment).

<figure><img src="/files/akrOU2hzeFKggSIJ00k0" alt="" width="375"><figcaption></figcaption></figure>

#### Input Fields

* **Variable:** Name of the variable to be referenced for usage.
* **Value:** Value stored in the variable
* **Description:** Entering some self-explanatory notes about the created variable

### CSV Upload

Similar to JMeter, Script Builder supports CSV file upload so you can use dynamic data in your tests by referencing predefined values from your dataset.

<figure><img src="/files/wWBV5o25j2Q9gcGdSQsc" alt="" width="375"><figcaption></figcaption></figure>

**Input Fields**

* **Variable Names:** Name of the variables to be referenced from CSV file (make sure to split your variable names by using ***comma***).
* **Delimeter:** The separator character used to split a dataset in a csv file.
* **Ignore first line:** Toggle this option if you have header line in your csv file.
* **Recycle on End of File:** Reuses the CSV data from the beginning after reaching the end.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.loadium.com/create-test/loadium-record-and-play.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
