How to add think time or wait time in Ajax TrueClient?

Adding Wait or Think Time in Ajax TrueClient Scripts.

There are different type of wait object to method present in ajax trueclient to add into the script. We will see the different option present and how they are different from each others. And also the purpose of each method. There are two ways we can add the wait in the trueclient script. So they are

  • Wait
    • It will wait for the duration provided in the wait step.
    • So the next will be triggered even if the step is ready.
  • Wait for Object
    • It will wait for the object until the object is present in page.
    • So that the previous page will wait still loading is completed.

Step 1 :

  • Launch the trueclient protocol in the Vugen.
  • And click on Develop script option in the script.
  • And record the flow , after that we can add the wait or wait for object to the script.

Ajax TrueClient Adding Transactions

Click Here to see how to record the script in Ajax TrueClient.

Step 2 :

  • Once you have recorded the flow completely. Then you can add the wait to the scripts.
  • Click on the Toolbox option present in the left side of the developer mode mode editor.
  • Under that option click on function bar.
  • And you will see the Wait and Wait for Object component present in it.

Wait Time in Ajax TrueClient

 

Step 3 :

  • Choose Wait component form the toolbox.
  • Drag and place the Wait after the step where you want it to be placed.
  • So the Wait component will be added to the script.
  • And also you can edit the Wait time in that step.
  • So you can mention how many seconds or minutes the wait step wait.
  • By default the value will be 3 seconds.

Step 5 :

  • Lets add Wait for Object in the step.
  • Choose Wait for Object component form the toolbox.
  • Drag and place the Wait for Object after the step where you want it to be placed.
  • Click on Click to Choose an Object from the Component.
  • And a finder section widow will be displayed. Where you need to select the object to wait.

Step 6 :

  • Once you select the object for which the script should be waiting.
  • You can also change the xpath of the wait object.
  • And now you can run the script.

 

How to do parameterization in Ajax TrueClient Script?

Parametrization in Ajax TrueClient Script.

Adding Parametrization to the script in Ajax TrueClient Script.

Step 1 :

  • Launch the trueclient protocol in the Vugen.
  • And click on Develop script option in the script.
  • And record the flow , after that we can add the parameter for the script.

Ajax TrueClient Adding Transactions

Click Here to see how to record the script in Ajax TrueClient.

Step 2 :

  • Once you have recorded the flow completely. Then one can add the parameter to the scripts.
  • So select the step in the flow for which you want to add the parameter.
  • Click on the step. Then select click on Js option in the step.

Parameterization in Ajax TrueClient Script

Step 3 :

  • Select the word or the variable which you want to parameterize.
  • Right click on the word.
  • And select the Create a New Parameter from the selection.

Parameterization in Ajax TrueClient Script

Step 4 :

  • Enter Parameter window will be displayed.
  • Enter the Name of the parameter.
  • And then Click on OK Button.

Step 5 :

  • And so the Original value will be replaced with parameter.
  • And Click on OK button of the editor.
  • Function used for parameter is TC.Param("P_BaseURL");
  • Now the value in the Step will be replaced with parameter as shown below.

Ajax TrueClient LoadRunner Tutorials

Ajax TrueClient LoadRunner Tutorial

Training Summary

Ajax TrueClient protocol in the loadrunner.  Ajax TrueClient protocol is mainly used to do the user side testing or the behavior of the browser side. So it is a heavy protocol due to which the number of load generator for the execution will be more compared to web scripts.

Syllabus


1. Tutorial  -> How to record Ajax TrueClient script in Loadrunner.


2. Tutorial -> How to add Parametrization in Ajax TrueClient script.


3. Tutorial -> How to Capture the values in Ajax TrueClient script.


4. Tutorial -> How to add Transactions in Ajax TrueClient Script.


5. Tutorial -> How to Call external C- Function in Ajax TrueClient Script.


6. Tutorial -> Adding VTS Functions to the Script.


7. Tutorial -> Different Vuser Function present in Ajax TrueClient Script.


8. Tutorial-> Interview Questions for Ajax TrueClient Script.


9. Tutorial-> Quiz related Ajax TrueClient Script.

How to call C Function in Ajax TrueClient?

Call C Function in Ajax TrueClient Script

C Function in ajax trueclient is used to write your own custom code in the C-function.c file. Then call the function in your script to execute the custom code.

We will see how to call the C function from the ajax 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 :

  • Call the C function using the TC.evalC function.
  • Syntax : TC.evalC(Functionname,timeout);
    • Functionname : Name of the function which you will be calling from the C Function file.
    • timeout : You can specific how long you want the function to wait for completing it.
  • So the function looks like this TC.evalC("Demo",20);  after you entering the required field data.
  • And also  we will add the message so that we can see the message in the output panel once the function is successfully called.
  • After writing the function click on OK button.

Click Here to know more about the Ajax TrueClient functions.

Step 4 :

  • Now go to the C-function file and select the file.
  • Write your custom code in the C-Function file.
  • Save the script.
  • Close the Developer mode of the trueclient script.

Step 5 :

  • Once the developer mode is closed and the script view is enabled.
  • Save the script again and click on Run button.
  • So the script will be executed end to end without any error message.
  • Go to the output panel, you will see the message when the function is called and the custom code as well.
  • Below is the example how it will be displayed in the output panel.

 

How to add transactions in Ajax TrueClient?

Adding Transaction in Ajax TrueClient Script.

There are two ways to add the transaction to the script in ajax trueclient script. We will see both the ways 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 , for which the transaction should be added.

Ajax TrueClient Adding Transactions

Click Here to see how to record the script in Ajax TrueClient.

Step 2 :

  • Once you have recorded the flow completely. Then one can add the transaction to the scripts.
  • So select the step in the flow for which you want to add the transactions.
  • Right Click on the selected step. Then select the star transaction option.

Step 3 :

  • Once you click in Start Transaction link.
  • Transaction window will be displayed.
  • Enter the Transaction name in that and click on OK button.

Step 4 :

  • And again select the step in the flow for which you want to end the transactions.
  • Right Click on the selected step. Then select the End Transaction option.
  • You will see the Transaction name which you have added to start the transaction.
  • Click on the Transaction Name. (Right Click -> End Transaction -> Demo_Transcation_01).
  • So the transaction will be added the script.

Step 5 :

  • We have another way to add the transaction to the script.
  • Transaction icon on top of the panel will be displayed. Click on that icon.
  • Transaction Editor Window will be displayed.

Step 6:

  • So there will be a + plus button in the transaction editor window. Click on that icon.
  • We will find three section in that editor.
    • General - > Name : 
      • Enter the name of the transaction in that field.
    • Start Point :
      • Step : Select the Step from the drop down, where you want to add the start transaction.
      • Event : And also the select the event from the drop down.
    • End Point : 
      • Step : Select the Step from the drop down, where you want to add the end transaction in the flow.
      • Event : And also the select the event from the drop down.
  • Click on OK button.

Step 7 :

  • Once you have click OK on the editor.
  • Then the transaction will be added to the script.
  • Transaction will be added to the script. Save the script and close the developer mode.
  • So Click on Run button and the script will give you the result as shown below.(If the transaction result are not displayed in the reply window then go and change the setting as Tools-> Options ->Scrpting -> reply (Select "Collect reply Statistics ") )

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.

Top10 Ajax TrueClient Functions Present in Loadrunner

Top 10 Ajax TrueClient Functions

Below are the list of important ajax trueclient functions present in loadrunner.

Utils.clearCookies :

  • One can clear the cache of browser for each a single Vuser.
  • So the content of the whole cache simulator is unaffected.
  • But the function is not supported in the Chromium browser.
  • But it is supported in IE and Firebox browser.
  • Syntax : Utils.clearCookies();
  • Example : Utils.clearCookies();

Utils.clearCookies :

  • Removes all cookies currently stored by the Vuser.
  • So all cookies for each iteration will be cleared.
  • Syntax : Utils.clearCookies();

Utils.addAutoHeader :

  • One can add the custom header to the script.
  • So you can use this function to send the header value to the script.
  • Syntax : Utils.addAutoHeader(header, value, merge);
    • header. (String) name of the header to be added.
    • value. (String) value of the header to be added.
    • merge. (Boolean) True value indicates to merge the value with an existing header by the same name, false indicates to overwrite it.
  • Example : Utils.addAutoHeader("someCustomHeader", "someValue", true);

Utils.cleanupAutoHeaders :

  • So it removes all HTTP headers in the script.
  • And also stops adding HTTP headers to every consecutive HTTP request following this function call.
  • Syntax : Utils.cleanupAutoHeaders();

TC.setParam :

  • It is used too save the string value to a parameter or to a other value.
  • So the equivalent function used in web script is : lr_eval_string.
  • Syntax : TC.setParam(name, value);
    • name. (String) The name of the parameter in which to save the value.
    • value. (String) The parameter value.
  • Example: TC.setParam("myparam", "paramVal");

TC.outputMessage :

  • It is used to display the message on the output panel of the Vugen.
  • But if your running the script in performance center or controller it will wrote the message to the Vuser logs.
  • One can also append the parameter values in the message using +.
  • So the equivalent  function used in web script is : lr_output_message.
  • Syntax : TC.outputMessage(text);
    • text. (String) The message text.
  • Example: TC.outputMessage("My output message");

TC.getParam ;

  • It will returns the value of the specified parameter from the file.
  • So you can use that parameter in the script.
  • Syntax :  TC.getParam(name);
    • name. (String) The parameter name.
  • Example : TC.getParam("Filename");

TC.log :

  • It is also used to send the message to the Vuser log file.
  • But it will not display the message in panel during the test execution in the controller or performance center.
  • So you can send the status of the message using the available level.
  • Syntax : TC.log(text, level);
    • text. (String) The message.
    • level. Optional argument. One of the following:
      • "Error"
      • "Warning"
      • "Standard" (default value)
      • "Extended"
      • "Status"
      • "Status_msg"
  • Example: TC.log("my warning", "Warning");

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.
  • So the 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.
  • So the 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.vtcPopCell :

  • It will return the first row value of the column specified.
  • But it will delete the value from the cell.
  • So the 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.vtcClearColumn :

  • It will clear all the values in the column.
  • So the 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.
  • So the equivalent method in LoadRunner: lrvtc_disconnect.
  • Syntax : TC.vtcDisconnect(vtsName);
  • Example : TC.vtcDisconnect( "MyVts");

Ajax TrueClient Vuser Functions

Ajax TrueClient Vuser Functions

Below are the list of Vuser functions present in Ajax TrueClient Functions.

TC.setParam :

  • It is used too save the string value to a parameter or to a other value.
  • So the equivalent function used in web script is : lr_eval_string.
  • Syntax : TC.setParam(name, value);
    • name. (String) The name of the parameter in which to save the value.
    • value. (String) The parameter value.
  • Example: TC.setParam("myparam", "paramVal");

TC.outputMessage :

  • It is used to display the message on the output panel of the Vugen.
  • But if your running the script in performance center or controller it will wrote the message to the Vuser logs.
  • One can also append the parameter values in the message using +.
  • So the equivalent  function used in web script is : lr_output_message.
  • Syntax : TC.outputMessage(text);
    • text. (String) The message text.
  • Example: TC.outputMessage("My output message");

TC.log :

  • It is also used to send the message to the Vuser log file.
  • But it will not display the message in panel during the test execution in the controller or performance center.
  • So you can send the status of the message using the available level.
  • Syntax : TC.log(text, level);
    • text. (String) The message.
    • level. Optional argument. One of the following:
      • "Error"
      • "Warning"
      • "Standard" (default value)
      • "Extended"
      • "Status"
      • "Status_msg"
  • Example: TC.log("my warning", "Warning");

evalXPath :

  • Used to save to the path of object on the page.
  • And also you can use the value to write your logic.
  • Syntax : evalXPath(xpath);
    • xpath. (String) The xpath query.
  • Example : evalXPath("//a[text()=\" New Mercury Tours \"]");

TC.evalC :

  • It is mainly used to call the C function from the trueclient script.
  • Function that is defined in the C-functions.c file.
  • Syntax : TC.evalC(funcname, functimeout).
    • funcname. (String) The function name.
    • functimeout. (Number) The maximum expected runtime, in seconds, of the function called by the step.
  • So one can also specify the limit that function should take to complete.
  • Example : TC.evalC("myFunc", 20);

Syntax :

TC.vuserStatusMessage :

  • It is mainly used to indicates which Vuser is handling the particular script.
  • So you can use this function to check which user is executing the script.
  • Syntax : TC.vuserStatusMessage(text);
    • text. (String) Any text string.
  • Example : TC.vuserStatusMessage("FlightStatus");

TC.getParam ;

  • It will returns the value of the specified parameter from the file.
  • So you can use that parameter in the script.
  • Syntax :  TC.getParam(name);
    • name. (String) The parameter name.
  • Example : TC.getParam("Filename");

TC.advanceParam :

  • It is used to specify parameter to the pick the next value in the file.
  • So this is mainly used for the parameter of type file or unique number.
  • But the equivalent  function used in web script is : lr_advance_param.
  • Syntax : TC.advanceParam(name);
    • name. (String) The name of the parameter to advance.
  • Example : TC.advanceParam("multi_row_param");

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");

How to record Ajax TrueClient script in Load Runner?

Ajax TrueClient Scripting

TrueClient Protocol or TrueClient Scripting is getting more popularized in the recent times. It will give you the client side metrics like how long the page took to load the images. So customer are really intersected to know the time taken to render the application.  Therefore the TrueClient scripting or protocol is getting more important and popularized.

How to Record Ajax TrueClient Script in Load Runner

1: Launch  the Vugen Application.

2: Select a new script from the Vugen and then TrueClient - Web Protocol from the protocol windows as show below.

3: Once the TrueClient Script window is displayed. Navigate to Record -> Develop Script or Click on Develop Script from the shortcut displayed. Develop script mode will be launched. (Note : Recording, Adding Transactions and parameterization or any action on the script need to be done in Develop mode only. Therefore you cannot edit or do any change in the view mode in Ajax TrueClient). Develop mode consist of two panel,

  • First panel is TrueClient panel where you will be recording step of the user action and modification of script is done in this panel.
  • Second Panel which is a preview window, where application will be displayed and the action are performed. It is a same as the google browser where you can perform the actions.

4 : Click on record option from the TrueClient panel and paste the URL of the application in the browser(Second panel).

5 : After completing the recording of the user action. Stop button in the recording section should be clicked in the TrueClient Panel

6 : Run the script and validate the script if the script have successfully completed. Once running the script completed you will seen Replay Successful and importantly all the step will have tick mark beside it.