Last modified on January 15, 2020.

After you created a project in LoadNinja, you need to create scripts. A script is a sequence of user actions to be simulated on the tested website. In LoadNinja, you create scripts by recording them. You can record multiple scripts in your project. You then include scripts into a load test to have virtual users simulate different visitor workflows on the website. In this tutorial, we will record just one scripts. You can record more once you learn how it works.

In LoadNinja, you can start recording from multiple locations: from the topmost toolbar, from the project screen, or from the Dashboard. For now, let’s stick on the project screen. To start recording:

  1. On the Web Tests tab of the project screen, click Record:

    Start recording a script

    Click the image to enlarge it.

  2. In the subsequent dialog, you first need to specify whether the application you want to test is External (available to Internet users), or Internal (located within the local network of your company).

    This tutorial describes how to create script for an external web application, so select this option for now. To learn about recording tests against internal web applications, see Test Web Apps in Local Network With Endpoint.

  3. Next, you need to specify the URL of the web page from which your test will start, and select a screen resolution for the recording (some web applications may look and behave slightly differently on different screens).

    In our example, we will record a script on a sample pet store web application:

    Enter the URL and select the 1366×768 resolution.

    Note: In Advanced options, you can specify the location you want to use for the recording and further playback of the test. Let’s use the default one — US East (N. Virginia). You can change this in the recorder settings later, if needed.

    Ready to go? Click Start Recording.

    Enter the URL, screen resolution and start

    Click the image to enlarge it.

  4. You are now on the recorder screen. You see the tested web application on the right (in the internal browser area), and the recorded events on the left:

    The Recorder screen

    Click the image to enlarge it.

    To record a script, work with the tested web application in the internal browser as an end-user will work with it: click links, enter text, scroll pages, and so on. LoadNinja will be recording your actions and include them into the script.

    For example, let’s test the login system of the application:

    1. Click Log in.

    2. In the Returning Customer form, specify these credentials:

      • Login: user
      • Password: user
    3. Click Sign in.

    LoadNinja will record all these actions. You will see them on the left. The parent node corresponds to the web page, child nodes correspond to user actions and other events.

    First recorded commands

    Click the image to enlarge it.

    In LoadNinja, the parent nodes are called Steps. In single-page web applications, parent nodes correspond to application screens.

  5. Let’s record some more actions. Let’s check if our pet store offers poodle puppies: click within the search box at the page’s top, enter poodle there, and click Search:

    Search for poodle puppies
  6. Now, we need to check if the search results have any information. To do this, let’s add a validation to our script (validations help you check the server responses and verify that the tested web application works as expected). In our case, the validation should check whether the search result web page contains the word “Puppy”. To add this validation:

    1. Select Add > Validation on the toolbar on the left.

    2. In the subsequent Add Validation dialog, select the Text validation type.

    3. Enter the validation name.

    4. Select the Page Contains validation type, and then specify Puppy in Value.

      Adding a validation

      Click the image to enlarge it.

    5. Click Test to make sure the validation works. Then, click Add. You will see the validation added to the Search for Poodle test step:

      A validation command in the script

      Click the image to enlarge it.

    Tip: In LoadNinja, you can also create JavaScript validations. They have the same access to web page elements that script code running on the page has, and you can use them to perform any, even complex, checks. The validation JavaScript function must return true if it passes successfully, or false otherwise.
  7. Click to finish the recording for now.

  8. Click Play to run the recorded script to check it works correctly.

    Note: On the recorder’s bottom, a log is available; use it to immediately check how your website responds to your script’s commands.

    The dialog that appears at the end of the run shows the short excerpt of the playback results.

    Playback results

    Click Save and Run Load Test.

  9. In the subsequent dialog, enter the name of your script (select a descriptive name), and make sure that your project is selected in the Project drop-down list. Then, click Save Script and Continue:

    Save Recording dialog

    Click the image to enlarge it.

OK, you have recorded and saved your first script. Now, we will create a load testing scenario.

Prev     Next

See Also

LoadNinja Tutorial

Highlight search results