How to add VTS functions in Ajax TrueClient script

Adding Ajax TrueClient VTS functions to the Script

We will see how to add the vts function to the trueclient script step by step.

Step 1 :

  • Launch the trueclient protocol in the Vugen.
  • And click on Develop script option in the script.
  • And record the flow or you can add the functions before itself.

Add Ajax TrueClient VTS functions : Script

Click Here to know how to record the script in trueclient

Step 2:

  • Drag and drop the Evaluate Java script into the trueclient panel from the miscellaneous section.
  • And click on the js option present in the Evaluate Java script option.
  • Once you click on the js option, the working area will be displayed.

Add Ajax TrueClient VTS functions : Java script

Step 3 :

  • You should be knowing the VTS server name and port number. If not then fellow the steps.
    • Launch the VTS Server where it has installed..
    • And the copy the server name of the VTS. Here the VTS server name is localhost.
    • And also copy the port number which is used to communicate with the server. Port number is 8888.

Add Ajax TrueClient VTS functions: VTS Server

  • So if you know the server and port number of the VTS then you can skip to step number 4.

Step 4 :

  • And the working area will be displayed once the js option is clicked.
  • Add the vts connect function which is used to connect to the VTS server.
    • TC.vtcConnect(serverName, port, vtsName);
    • serverName: which we copied from the VTS server.
    • Port : Number which is used to communicate to the server which we copied in the last step.
    • vtsName: It the alias name which will be used to add,get,clear or disconnect from the VTS server.
  • So the function will be as below
    • TC.vtcConnect("localhost", 8888, "vtsdemo");
  • But to verify the connection let add a verifying logic to check if the connection is successful to the VTS server or not.
  • So click on OK after entering the details.

 

Step 5:

  • Now add Evaluate Java script again for sending the data to the VTS server.
  • And add the below code in the editor and click on ok button.
  • TC.vtcAddCell("P_Address", "1665656 Road", "vtsdemo");

Step 6 :

  • And again add one more Evaluate Java script from the miscellaneous section for disconnecting from the VTS server.
  • Add the vts disconnect function which is used to disconnect from the VTS server.
    • TC.vtcDisconnect(vtsName);
    • vtsName: The same alias name which will be used during connecting to the VTS server.
  • So the function will be as below
    • TC.vtcDisconnect("vtsdemo");
  • But to verify the connection let add a verifying logic to check if the connection is successful disconnected the VTS server or not.
  • Click on OK after entering the details.

Step 7 :

  • And save the script and click on run button.
  • You will see count of data sent to the VTS on the Refresh button.
  • So once you see the count click on Refresh button and the data will reflect which is sent to the VTS server from the script.
  • But the output message will not be displayed in the developer mode. Check next step to see the output message.

Step 8 :

  • So once the script is running end to end without any error message.
  • Close the developer mode of the trueclient.
  • Save the script again and click on run button.
  • So you will see the message on the output panel for connecting and disconnecting from the server.
  • And also the data will be entered in the VTS server.

Ajax TrueClient VTS Functions

Ajax TrueClient VTS Functions

Below are the list of Ajax TrueClient VTS Functions present in loadrunner and there examples.

TC.vtcConnect :

  • It is used to established the connection from the scripts to the VTS server.
  • So it will open the connection from the script to VTS server and the connection will be open until it is disconnected.
  • Equipment function used in web script  is  : vtc_connect.
  • Syntax : TC.vtcConnect(serverName, port, vtsName);
    • serverName. (String) Either the IP or server name.
    • port. (Integer) The port number
    • vtsName. (String) The alias of the VTS server.
  • Example : TC.vtcConnect("MyServer", 8888, "MyVts");

TC.vtcAddCell :

  • Used to add or send a value to a column specified.
  • So the values will be added to the end of the column.
  • But if the column name is not present in the VTS server, then it will create the column name and add the value.
  • Equipment function used in web script  is  : lrvtc_send_message.
  • Syntax : TC.vtcAddCell(colName, value, vtsName);
    • colName. (String) The name of the column.
    • value. (String) The value as a string.
    • vtsName. (String) The alias of the VTS server.
  • Example :  TC.vtcAddCell("P_Address", "1665656 Road", "VTS_Name");

TC.vtcAddCells :

  • It is used to add multiple values into the VTS using this function.
  • So the values will be added to the end of the specified column.
  • But if the column name is not present in the VTS server, then it will create the column name and add the value.
  • Equipment function used in web script  is  : vtc_send_row1.
  • Syntax : TC.vtcAddCells(colNames, values, option, vtsName);
    • ColNames. (String) Column names delimited by a semi-colon.
    • values. (String) The values as a string delimited by a semi-colon.
    • option. (Integer) Define how the values are added.
      • 0. Add as same row in all columns based on the column with the highest row count. The created row will be n+1 for all columns.
      • 1. Add as stack - last row in every column.
      • 2. Add as unique stack - last row in every column only if the value is unique in the column.
  • vtsName. (String) The alias of the VTS server.
  • Example : TC.vtcAddCells( "MyColumn1;MyColumn2;MyColumn2", "MyValue1;MyValue2;MyValue3", 0, "MyVts");

TC.vtcGetCell :

  • It will return the first row value of the column specified.
  • But it will not delete the value from the cell.
  • It will just copy the values from the column.
  • Equivalent method in web script is : lrvtc_query_column.
  • Syntax : TC.vtcGetCell(colName, rowIndex, vtsName);
    • colName .(String) The name of the column.
    • rowIndex. (Integer) The index number of the field as an integer. 1 is the first field in the column.
    • vtsName. (String) The alias of the VTS server.
  • Example : TC.vtcGetCell("MyColumn",1,"MyVts");

TC.vtcPopCell :

  • It will return the first row value of the column specified.
  • But it will delete the value from the cell.
  • Equivalent method in web script is : lrvtc_retrieve_message.
  • Syntax : TC.vtcPopCell(colName, vtsName);
    • colName .(String) The name of the column.
    • vtsName. (String) The alias of the VTS server.
  • Example : TC.vtcPopCell("MyColumn","MyVts"); 

TC.vtcClearCell :

  • It is used to clear the value in the column.
  • By default it will clear the first value in the columns. But you can specific the cell number also which one you want to delete.
  • Equivalent method in LoadRunner: lrvtc_clear_message.
  • Synatax : TC.vtcClearCell(colName, rowIndex, vtsName);
    • colName. (String) The name of the column.
    • rowIndex. (Integer) The index number of the field as an integer. 1 is the first field in the column.
    • vtsName. (String) The alias of the VTS server.
  • Example : TC.vtcClearCell("MyColumn",1,"MyVts");

TC.vtcClearColumn :

  • It will clear all the values in the column.
  • Equivalent method in LoadRunner: lrvtc_clear_column.
  • Syntax : TC.vtcClearColumn(colName, vtsName);
    • colName.(String) The name of the column.
    • vtsName. (String) The alias of the VTS server.
  • Example : TC.vtcClearColumn("MyColumn","MyVts");

TC.vtcDisconnect :

  • It is used to disconnect the VTS connection from the server.
  • Equivalent method in LoadRunner: lrvtc_disconnect.
  • Syntax : TC.vtcDisconnect(vtsName);
  • Example : TC.vtcDisconnect( "MyVts");