Last modified on October 8, 2020.

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:

    https://petstore.smartload.io/applicationPetstore/shopping/main.xhtml

    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 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 UI test

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

  7. If you’ve recorded a test for the first time, LoadNinja will display a message box suggesting that you run the test at least once to ensure it works as expected. (If you recorded tests earlier and selected Don’t show again in the message box, you will not see it.)

    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.

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

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

    Playback results

    If everything is OK, click Save and Run Load Test to create a load test scenario.

    If errors occurred, fix them before you proceed.

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

    Save Recording dialog

    Click the image to enlarge it.

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

Prev     Next

See Also

LoadNinja Tutorial
UI Tests (or Scripts)

Highlight search results