Applies to LoadNinja 1.0, last modified on October 17, 2019

A script (or web test) is a sequence of user actions that LoadNinja uses to simulate virtual user behavior on the tested web application. To view the contents of scripts you create, use the LoadNinja script recorder.

Open the recorder

At design time
  1. Click Projects at the top.

  2. Click a project name to view all scripts in that project.

  3. Click the test name.

    Open the script recorder

    Click the image to enlarge it.

During recording

LoadNinja opens the script recorder automatically after you start recording. As you record actions in your web application, they will appear in the script recorder.

Recorder layout

The script recorder consists of two parts. The left side displays your test, individual test steps and events. The right side is an embedded web browser, where you record actions against your web application, and where you watch it during the test playback.

The script recorder

Click the image to enlarge it.

A script consists of steps, which consist of events. Steps usually correspond to individual web pages in an application, and events correspond to user actions such as link clicks or keyboard input.

LoadNinja records a new step when the URL in the browser address bar is changed. To insert a new step manually, click Add > Step. This is especially helpful when recording tests for single-page applications (SPA) where the URL does not change.

Note: The maximum number of test steps for a load test scenario is 25 regardless of the plan you have. If a scenario uses several scripts, the total number of their steps should not exceed this number. This limit means that a script can have 25 steps maximum. You can see the number of used and available steps during test recording at the bottom of the script editor. The total number of used steps is visible in the Scenario editor.

Toolbar

Item Description
File The File drop-down menu includes the following commands:
  • New — Start recording a new script.
  • Open — Close the current script and open another.
  • Save — Save the current script using either the existing name or a new name. The log is part of the script and is saved along with script data.
  • Exit — Close the script recorder.
 Record Start recording a new script.
 Playback Run the recorded test.
Note: If the test run completes successfully, you can run a load test based on the executed script from the Playback Results dialog.
 Stop Stop recording.
Add  The Add drop-down menu includes the following commands:
  • Step — Append a new synthetic step to the test. This is helpful when recording a test against single-page web applications (SPA). Such applications use the same URL for their screens. Using this command, you can organize the recorded events in steps to make it easier to view and maintain them in the future.
  • Databank — Attach a databank to the test to parameterize the event parameters with values from this databank.
  • Validation — Insert a validation to the test to check if the tested web application functions properly.
  • URLs to block — Open a dialog to specify a list of third-party URLs LoadNinja will block when executing this script.
 Settings View or change the script settings.

Record more actions

Watch this video:

 

To record more actions and append them to the test:

  1. Locate the baseline item in the list on the Steps tab.

    You can record actions and add them to test after or before:

    • existing steps,
    • Click events,
    • Keyboard input events.
  2. Click and select Record new steps (or Record new actions) from the drop-down menu:

    The Add step menu item

    Click the image to enlarge it.

  3. In the subsequent dialog, choose whether you want to record a new action before or after the baseline item:

    The Add new steps dialog
    You cannot add a step before the first step.
  4. Click Record and Add.

  5. LoadNinja will replay the script from the beginning until the playback reaches the required point.

  6. Record the needed actions as usual.

  7. Click  Playback to run the modified script and see if it works correctly.

  8. Select File > Save on the toolbar to save your changes.

Edit event parameters

Think Time and Keyboard Input events
  1. Find the needed event in the editor and expand its parameters.

  2. Click next to the parameter, enter a new value, then click Submit.

    Change event parameters

    Click the image to enlarge it.

    Tip: To map the value of a Keyboard Input event to an external databank, click Map to External Databank in the dialog.
Click events
  1. Find the needed event in the editor and expand its parameters.

  2. Select the preferable way of identifying the click target on the page.

    To command LoadNinja to select the optimal method of object recognition using its AI capabilities, select the Let LoadNinja AI decide check box.

    To enable the AI object identification for the whole script, click on the recorder’s toolbar. In the subsequent dialog, select Let LoadNinja AI decide in the Object identification drop-down list.

    Select one of the following options:

    • Use XPath — LoadNinja identifies an object in the page’s DOM using an XPath expression that refers to the object's index within the document hierarchy.

      For example, the following expression refers a link located in the header of a specific block element:

      //html[1]/body[1]/div[2]/h1[1]/a[1]
    • Use Optimized XPath — LoadNinja identifies an object in the page’s DOM using an XPath expression that refers to the object or its parent unique identifier (the id attribute), where it is possible.

      For example, the following expression refers a link located in the header of the sample element, specified by its ID:

      //*[@id="sample"]/h1/a
    • Use CSS Selectors — LoadNinja identifies an object in the page’s DOM using a CSS selector.

      For example, the following expression refers a link located in the header of a specific block element:

      :nth-child(4) > h1 > a
    • Use Screen Coordinates — Use x and z coordinates of the object.

      The coordinate line consists of two numbers, for example:

      (95, 105)

      The first number refers the x axis, the second — the y axis.

Manage events and steps

Synthetic steps

There are cases when you need to group actions within your script logically. For example, the website you test might show a dialog window with a form. To logically separate the actions you perform while filling in the form from other actions, create a synthetic step — a logical block that combines the actions you perform with the form.

Note: It is also possible to create synthetic steps while recording a test, for example, to mark the difference between pages while testing against single-page applications. To learn more about this feature, see Test Single-Page Applications.
To create a synthetic step during recording
  1. Select Add > Step on the toolbar of the script recorder:

    Add a synthetic step

    Click the image to enlarge it.

  2. In the subsequent dialog, name the step as you like:

    Create New Synthetic Step dialog

    Click the image to enlarge it.

    Another way to create synthetic steps is to group recorded events and actions. To learn more about this functionality, see below.

All synthetic steps are marked with the icon in the step list.

To group existing actions and events into a synthetic step
  1. Locate one of the events you want to include in the synthetic steps, in the step list.

  2. Select  > Group into step.

    Edit action: Group into step

    Click the image to enlarge it.

  3. LoadNinja will enable the grouping check boxes. Select the ones near the events you want to group into step.

    Grouping: Check boxes

    Click the image to enlarge it.

  4. Click Group.

  5. (Optional) To rename the step, select  > Edit step name, specify a new name in the edit box, then press Enter.

Note: All actions and events within a specific step that you have not explicitly added to a synthetic step, LoadNinja will automatically collect into another synthetic step.
Synthetic step: Actions

Click the image to enlarge it.

  • Locate the synthetic step you want to rename.

  • Select  > Edit step name.

  • Specify a new name in the edit box.

  • Press Enter.

By ungrouping, you remove the synthetic step from the step list. This action does not affect the events and actions that the step contains. All of them will be preserved and moved to the step above.

  1. Locate the synthetic you want to ungroup, that is, remove from the step list.

  2. Select  > Ungroup step.

To learn how to delete a step completely, along with all actions and events it contains, see Delete events or steps.

Delete events or steps

Select  > Delete next to the step or event you want to delete.

Delete a test event or step

Notes:

  • Deleting a step deletes all events in it.

  • Deleting a keyboard or mouse event also deletes the Think Time command before it.

Upload files

In LoadNinja, you can upload files to your tested web application during script recording. This may be needed if, for example, your application requires that users upload some files to the application and you want to test this functionality. See Upload Files for more information.

Block URLs

You can command LoadNinja to block requests to certain resources while replaying scripts in the recorder or during load test runs. These resources may include unwanted advertisement banners, tools you use to gather visitor statistics (such as Google Analytics), and so on.

To provide a list of such unwanted resources, select Add > URLs to block on the script recorder’s toolbar.

For more information, see Block URLs.

Playback log

You can find the log at the bottom of the script editor. You use it to check how the test engine simulates events during the script playback.

To learn more about the log, see Playback Log.

More actions

To rename a script
  1. Click next to the script’s name.

  2. Enter a new name for the script and press Enter.

    Rename a script
To save a script under another name
  1. Select File > Save on the toolbar.

  2. Enter a new name for the test, and click Save.

    Save a script under a new name

    Click the image to enlarge it.

To move a test to another project
  1. Click File > Save on the toolbar.

  2. Select the target project, optionally, enter a new name for the test, and click Save.

    Move a test to another project

    Click the image to enlarge it.

To delete a test
  1. Click Projects at the top.

  2. Click the project that contains the test you want to delete.

  3. Select the check boxes next to the tests you want to delete and click Delete at the upper right.

    Delete scripts

    Click the image to enlarge it.

See Also

Scripts
Validations
Using Databanks in LoadNinja Tests

Highlight search results