2. Record UI Test

Last modified on November 15, 2022

After you created a project in LoadNinja, you need to create a test. In LoadNinja, you can create UI tests or API tests:

  • A UI test (or script) is a sequence of user actions – mouse movements, clicks, keystrokes, and so on – to be simulated on the tested website. You create these tests by recording user actions on the tested web pages. You can record multiple UI tests for your project.

  • An API test is a sequence of HTTP or HTTPS requests to be sent to the tested web service. You create these tests by entering request parameters manually.

Let’s record a UI test:

  1. On the Tests tab of the project screen, click Create Test and select UI test from the context menu:

    Start recording a UI test

    Click the image to enlarge it.

  2. In the subsequent dialog, you 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 UI test on a sample pet store web application:


    Enter the URL and select the 1366×768 resolution:

    Enter the URL, screen resolution and start

    Click the image to enlarge it.

    The dialog box has two more settings:

    • From the drop-down list, you can select the location to use for the recording and further playback. This is helpful when you need to check how your website works for users located in different regions of the world. By default, LoadNinja selects the region that better matches your location. Let’s keep this default value.

    • Web applications that reside in your local network or on your computer require special recording steps. Select the This website is not publicly available check box, start recording and follow the instructions you will see on the screen. For more information, see Test Web Apps in Local Network.

      The tested app we use in our tutorial is publicly available, so we can keep the check box unselected.

    OK, ready to go? Click Start Recording.

  3. 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 UI test, 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 test (see Recording UI Tests - Best Practices for more information).

    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.

  4. 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
  5. Now, we need to check if the search results have any information. To do this, let’s add a validation to our test (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.

    2. In the subsequent Validations dialog, choose Text Validation from the drop-down list:

      Creating a Text validation

      Click the image to enlarge it.

      This will invoke the dialog box with the validation settings:

      Text Validation settings
    3. In the dialog:

      • Enter the validation name, for instance, checkPoodle.

      • Select the Page contains validation type, and then specify Puppy in the Value box.

      • In the Add to Step box, select the last recorded step —Search for poodle.

      • You also need to choose the test engine behavior in case the check fails (that is, in case the tested page doesn’t have the specified text). In this tutorial, we can select Fail immediately. For information on possible options, see the validation description.

        Now, the dialog box looks as follows:

        Adding a validation
    4. Click Test to make sure the validation works.

    5. If the validation completed successfully, click Add Validation. LoadNinja will notify you that the validation was created successfully and will return back to the Validations dialog box:

      Validations dialog box

      Click OK to close the dialog.

    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.
  6. Click to finish the recording for now:

    Stop recording

    LoadNinja will display a message box suggesting that you run the recorded test at least once to ensure it works as expected:

    Message to play back the recorded test

    The playback will start automatically. We don’t recommend skipping it. If for some reason you decided to play back the test later, you can do this any time by clicking Play at the top left of the recorder screen:

    Play back the recorded test

    Use the Playback Log at the bottom of the recorder screen to immediately check how your website responds to your test’s commands:

    The Playback Log panel

    Click the image to enlarge it.

  7. At the end of the run, LoadNinja shows a short excerpt of the playback results:

    Playback results

    If errors occurred, fix them before you proceed.

    If everything is OK, you can create a load testing scenario. To do this, click “Save and Run Load Test”. LoadNinja will ask you to save the recorded UI test first and then will display a special dialog box with scenario settings. If you click “Save Script” or “Save Script As”, LoadNinja will save the recorded test, and you will need to create a load testing scenario from another screen of the product (see Scenarios for details).

    Let’s click Save and Run Load Test as this is a simpler and faster way at the moment. We’ll describe your actions in the next step of this tutorial:

    Start creating the load testing scenario

Prev     Next

See Also

LoadNinja Tutorial
UI Tests (or Scripts)

Highlight search results