Configure TruWeb for your IDE

You can build a TruWeb script using your favorite IDE or text editor.

This topic provides examples for working with some common tools.

Scripting with JetBrains WebStorm (IntelliJ)

This example demonstrates how to create a TruWeb script using WebStorm (IntelliJ). You can use the existing EmptyScript template as a base.

Autocomplete: If you do not start your script from the EmptyScript template, then in order to activate autocomplete capabilities you should copy TruWebSdk.d.ts to the script folder. This file is available from the following sources:

  • <TruWeb installation path>/examples/EmptyScript
  • Fetch the one located in the TruWeb empty script template in the Micro Focus GitHub repository. Note that if you are not using the latest version of TruWeb, it might not fit perfectly.

To set up and write the script with WebStorm:

  1. Copy the EmptyScript folder from \<TruWeb installation>\examples\ to a location on the same machine as TruWeb.

  2. Rename the folder, for example, MyTruWebProject.
  3. In WebStorm, open the MyTruWebProject project.
  4. In the Project view, under the MyTruWebProject project, open main.js to start writing your code.
  5. To enable running the script in WebStorm, set up WebStorm to use the TruWeb executable:

    1. Select File > Settings.
    2. Select Tools > External tools, and click the + button.

    3. Configure TruWeb as follows:

      Click OK.

Back to top

Scripting with Atom.io

This example demonstrates how to create a TruWeb script using Atom.io.

To set up and write the script with Atom.io:

  1. Prerequisite: Download and unzip the TruWeb plugin file for Atom.io:

    • Windows. Unzip to C:\Users\<user name>\.atom\packages
    • Linux/MacOS. Unzip to ~/.atom/packages

    When you open Atom.io, the TruWeb menu should appear.

  2. Copy the EmptyScript folder from \< TruWeb installation>\examples\ to a location of your choice.
  3. Rename the folder, for example, MyTruWebProject.
  4. In Atom, open the MyTruWebProject folder and double-click main.js in the project tree to start writing your code.

Back to top

Scripting with Eclipse

This example demonstrates how to create a TruWeb script using Eclipse. You can use the existing EmptyScript template as a base.

To set up and write the script with Eclipse:

  1. Copy the EmptyScript folder from \<TruWeb installation>\examples\ to a location on the same machine as TruWeb.
  2. In Eclipse, select File > Import Projects from File System or Archive. The Import Projects from File System or Archive wizard opens.

  3. In the Import source field, enter the path to the EmptyScript folder, or click Directory and browse to the folder. Click Finish.

  4. From Project Explorer, open EmptyScript > main.js to start writing your code.
  5. To enable running the script in Eclipse, set up Eclipse to use the TruWeb executable:

    1. Select Run > External Tools > Eternal Tools Configurations and click the New Configuration button.

    2. Enter a name for the configuration in the Name field, for example, "TruWebSingleRun".

    3. Under Location, enter the path to TruWeb. If relevant, you can use the TRUWEB_PATH environment variable using ${env_var:TRUWEB_PATH}, as in the example below.

    4. Under Working Directory, enter the path to the script.

    5. Under Arguments, add the following arguments, separated with a blank space:

      • -ide=eclipse
      • The path to the script, for example: C:\Scripts\EmptyScript

Back to top

Scripting with Visual Studio Code

This example demonstrates how to create a TruWeb script using Visual Studio Code (VS Code). You can use the existing EmptyScript template as a base.

To set up and write the script with Visual Studio Code:

  1. Copy the EmptyScript folder from \<TruWeb installation>\examples\ to a location on the same machine as TruWeb.
  2. Rename the folder, for example, MyTruWebProject.
  3. In VS Code, open the script folder: Select File > Open Folder and open the relevant folder.
  4. When the folder has loaded, select Terminal > Configure Tasks (in older versions of VS Code, select Tasks > Configure Tasks).
  5. Select Others from the dropdown list of task templates.
  6. Configure tasks.json as follows:

    Note: In older versions of VS Code, taskName might be used instead of the label key.

    {
      "version": "2.0.0",
      "tasks": [
        {
          "label": "TruWeb Single Run",
          "type": "process",
          "presentation": {
            "panel": "new"
          },
          "windows": {
            "command": "${env:TRUWEB_PATH}\\TruWeb.exe"
          },
          "osx": {
            "command": "${env:TRUWEB_PATH}/TruWeb"
          },
          "linux": {
            "command": "${env:TRUWEB_PATH}/TruWeb"
          },
          "args": [
            "-ide=vscode",
            "${cwd}"
          ]
        },
        {
          "label": "TruWeb Load Run",
          "type": "process",
          "presentation": {
            "panel": "new"
          },
          "windows": {
            "command": "${env:TRUWEB_PATH}\\TruWeb.exe"
          },
          "osx": {
            "command": "${env:TRUWEB_PATH}/TruWeb"
          },
          "linux": {
            "command": "${env:TRUWEB_PATH}/TruWeb"
          },
          "args": [
            "-mode=load",
            "-ide=vscode",
            "${workspaceRoot}"
          ]
        },
        {
          "label": "TruWeb Debug Run",
          "type": "process",
          "windows": {
            "command": "${env:TRUWEB_PATH}\\TruWeb.exe"
          },
          "osx": {
            "command": "${env:TRUWEB_PATH}/TruWeb"
          },
          "linux": {
            "command": "${env:TRUWEB_PATH}/TruWeb"
          },
          "isBackground": true,
          "presentation": {
            "panel": "new"
          },
          "args": [
            "-inspect",
            "-ide=vscode",
            "${workspaceRoot}"
          ]
        }
      ]
    }
  7. Select Terminal > Run Tasks (in older versions of VS Code, select Tasks > Run Tasks), then select TruWebSingleRun to run the TruWeb script. If any errors are discovered during the run, press CTRL+left mouse button to jump to the line where the error occurred.

Note: This example uses the environment variable TRUWEB_PATH, which should point to the TruWeb installation path. The environment variable is created automatically when TruWeb is installed using LoadRunner or Performance Center (LoadRunner Enterprise).

Back to top

See also: