Use VTS in TruClient scripts

This section describes VuGen Virtual Table Server (VTS) and how to use it in a TruClient script.

What is VTS?

  • VuGen Virtual Table Server (VTS) is a Web-based application that is built to work with VuGen Vuser scripts. VTS offers an alternative to standard VuGen parameterization.

  • When you use standard VuGen parameterization, each Vuser is assigned parameter values from a dedicated set of values - parameter values are not shared between Vusers. In contrast, VTS enables you to assign parameter values from a single set of parameter values to multiple Vusers. This may enable you to more accurately emulate a real-user environment.

  • VTS includes a table that contains parameter values that can be used by your Vuser scripts. The VTS table is composed of columns and rows. Each column represents a set of values that can be used by a specific parameter in your Vuser scripts. The cells within a column contain the actual values of the parameter.

Back to top

Install VTS

For details on installing VTS, see Installing the Virtual Table Server (VTS) in the VuGen Help Center.

Back to top

Connect to a VTS server

  1. Click Step in the toolbar, select Miscellaneous and drag an Evaluate JavaScript step to the desired location in the script.

  2. To connect to a VTS, enter one of the following in the Arguments > Code section of the step:

    • TC.vtcConnectEx(“serverName”, port, "UserName", "password", "domain", "alias") - supports HTTP, HTTPS, basic authentication, and NTLM authentication.

    • TC.vtcConnect(“serverName”, port, “alias”) - supports HTTP. 

    You can identify the server either by domain name or by IP address.

    Example: TC.vtcConnectEx("myServer",8888,"myUser", "myPW", "myDomain", "myVTS");

  3. To disconnect from a VTS, enter TC.vtcDisonnect("alias") in the Arguments > Code section of the step.

Tip:  

  • Before you replay the script, play the TC.vtcConnectEx step (from within the step) to verify the connection to the VTS server.

  • If you are unable to connect to a remote VTS server, configure the firewall on the VTS server machine, making sure the connection to the VTS port or process is enabled.

  • Once you have established a connection to the VTS server, you can play other VTS API steps, modify them and replay again.

  • Replaying the entire script will automatically disconnect the VTS even if there is no disconnect step in your script.

  • The VTS server supports port forwarding that redirects communication requests from one port to another. For details, see Enable port forwarding.

Examples of connecting and disconnecting to a server:

  • Using a server name and VTS name (alias):

    TC.vtcConnectEx(“MyServer”, 8888, “User1”, “userPW”, “userDomain”, “UsersTableVts”); 
    TC.vtcDiscconect(“UsersTableVts”); 

    For details on the use of aliases, see Why do you need an alias for your VTS server?

  • Using the server IP address and VTS name (alias):

     TC.vtcConnectEx(“192.168.1.133”, 8888, “Worker1”, “WorkersPW”, “WorkersDomain”, “WorkersTableVts”);
     TC.vtcDiscconect(“WorkersTableVts”); 
  • Using the server name without a VTS name (alias):

     TC.vtcConnectEx(“MyServer”, 8888);
     TC.vtcDiscconect(); 
  • Using the server IP address without a VTS name (alias):

    TC.vtcConnectEx(“192.168.1.133”, 8888);
    TC.vtcDiscconect(); 

Back to top

Enable port forwarding

Available in version: TruClient 2020 SP1 and later

If your VTS server can only open port 80 or 443 for inbound communications, but many VTS instances are already running on those ports, you can use port forwarding to redirect communication requests from one port to another. This enables you to connect to your VTS server and work normally.

To enable VTS port forwarding:

  1. Configure the server machine that hosts VTS service to support port forwarding. The machine should forward requests on port 80 to the true port passed in the URL's query string (portnumber).

  2. Enable port forwarding in TruClient.

    1. In the script folder, open the default.cfg file and set AccessVTSPortByQueryString=1 (in the "General" section).

    2. Change the port to one that your VTS server can open for inbound communications (the default ports are 80 for HTTP and 443 for HTTPS).

      • For HTTP: Change the value in VTSHTTPAccessPort to match the port that the VTS server is using (if it is not using port 80).
      • For HTTPS: Change the value in VTSHTTPSAccessPort to match the port that the VTS server is using (if it is not using port 443).

      For example, if your VTS server cannot open port 80, but can open port 8080, change the port value in VTSHTTPAccessPort to “8080”.

  3. Use the existing VTS API to connect to your VTS server.

    For example, TC.vtcConnect(“vtsServer”, 8888, “myVTS”);

Back to top

Why do you need an alias for your VTS server?

If you are using more than one server, creating an alias for each server will simplify identifying which VTS your are referencing in your code.

Back to top

Use Evaluate JavaScript code step to pass VTS parameters to another step

You can use the Evaluate JavaScript code step to pass VTS parameters to another step in your script. The example below shows you how to parameterize a URL.

  1. Connect to a VTS server

    1. Click Step in the toolbar, select Miscellaneous and drag an Evaluate JavaScript step to the desired location in the script.

    2. To connect to a VTS, enter TC.vtcConnectEx(“serverName”, port, "UserName", "password", "domain", "alias") in the Arguments > Code section of the step.

  2. Create a step that contains a variable.

    1. Click Step in the toolbar, select Miscellaneous and drag an Evaluate JavaScript step to the desired location in the script.

    2. In Argument > Code section enter define your variable.

      For example, to get data from the server enter var ws = TC.vtcGetCell("Web Sites",1,"alias");

  3. Click Step in the toolbar, select Functions and add an Generic Browser Action step to your script.

  4. Enter the variable you defined in Step 2 in Argument > Location.

Back to top

Use a VTS API function directly in a step

You can use the Evaluate JavaScript code step to call a VTS function in your script. The example below shows you how to parameterize a URL.

  1. Connect to a VTS server.

    1. Click Step in the toolbar, select Miscellaneous and add an Evaluate JavaScript step to your script.

    2. To connect to a VTS, enter TC.vtcConnectEx(“serverName”, port, "UserName", "password", "domain", "vtsName") in the Arguments > Code section of the step.

  2. Click Step in the toolbar, select Functions and add a Generic Browser Action step to your script.

  3. Enter TC.vtcGetCell("Web Sites",1,"alias");in the Argument > Location section of the script.

Back to top

See also: