Applies to LoadNinja 1.0, last modified on May 22, 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.

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 test using either the existing name or a new name.
  • 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

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.

    Possible options include —

    • 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

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.

More actions

To delete an event or a step

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.

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