AJAX TruClient – Tips and Tricks Part II


The more I work on TruClient protocol, the more challenges I face (to implement more and more functionalities in scripts / config changes) and the more I explore on TruClient. This exploration sometimes take me very long to resolve issues and help me learn many new things on the way. Through this article I would like to share with you some challenges that I faced while scripting and the different tips that I developed while resolving issues. I have also mentioned some config changes for day-to-day issues here. I hope the article helps you.

1) Calculating number of text occurances

Scripting of most of the modern internet applications with number of dynamic features demand this requirement. Be it to check the presence of a text (or object) on the web page, or to count the number of tickets generated in the application during run time, calculating text occurances and using this count with right logical code – is the need of the day. In AJAX, using JavaScript functions, we can achieve this objective. This is how we can do it –

1.    Drag ‘Evaluate Javascript code’ from toolbox
2.    In the arguments section add the following code –
var splitBySearchWord = (document.body.textContent).split(‘Text to search for);
3.    Then display the total number of occurance of the text using Alert() method.

2) Inserting random thinktime –

End-user behavior is unpredictable and as a performance test engineer, while executing a performance test, our aspiration should always be to reach closest to the real time scenario. Some end users may spend only 2 secs before navigating to next page, while many others may think for more time. Hence in many test scenarios, it would not be ideal to insert a fixed think time value before a web request; rather one must use random think time in such cases. This can be done using advanced javascript functionalities and these are the steps –

1) From ‘Toolbox’, copy a wait function and paste it before the web request.
2) In the argument section, replace the interval value ‘3’ by ‘Math.floor(11*Math.random()+5);

The above function will return a random number between 5 and 15.

Math.floor() method rounds a number DOWNWARDS to its nearest integer. (Eg. The output of code ‘Math.floor(1.8);‘ is 1). Hence 11 is used as a multiplication factor so that an integer in the upper decimals of 10 will be rounded to 10.
Math.random() method returns a random number between 0 and 1.

3) Handling browser cache

You may wish to manage the cache handling features of the browser to replicate different types of test scenarios. This can be achieved by following these steps –

1.    Open the Script under Interactive mode.
2.    Go to Vuser > Run-Time Settings > General > Load mode Browser Settings.
3.    Inside the Settings frame women extenze display the option Advanced.
4.    Select the option “Compare the page in cache to the page on the network”; select one of the four values above according to your test requirements.

  • 0 = Once per session
  • 1 = Every time the page is accessed
  • 2 = Never
  • 3 = When the page is out of date(this is the default value)

4) NTLM authentication

Some applications when accessed on Mozilla, demand NTLM authentication. If these steps appear while recording, they don’t get recorded. Hence while replaying, due to the absence of these steps, the application fails to perform the intended transactions.

To avoid a situation in which an application asks for NTLM authentication while recording and replaying, one has to specify the application as a trusted NTLM resource. To make that, follow these steps.

1) Open the file “user.js” located in “%lr_path%\dat\LrWeb2MasterProfile”
2) Locate the preference setting “network.automatic-ntlm-auth.trusted.uris”
3) Specify the URL of the trusted resource as the value of this setting
4) Save the file “user.js”

These changes are done only where the VuGen is used to develop the script. These changes get saved with the script and apply on different machines during load tests.

5) Memory Footprint of a TruClient Vuser

Ajax TruClient is a GUI level protocol and interacts with objects generated during run time while making any web-request. It doesn’t work like a regular HTTP user that interacts with the application server at transport level. As a result the Ajax TruClient user while test execution, uses browser instance, DOM, Javascripts, GDI resources, etc. It also does client side processing and page rendering of Javascript calls. All of this cause more memory consumption for an Ajax TruClient vuser as compared to that of a regular web HTTP user.

HP team’s benchmarks for various applications under test suggest that a single AJAX TruClient Vuser utilizes around 60-120 MB of memory footprint and consumes about 3 – 30% of Single CPU core (3GB Ram).

6) AJAX TruClient with Internet Explorer

The latest version (11th Version, 4th Patch) of Ajax TruClient is integrated only with Mozilla Firefox. However, HP is planning to release another patch with internet explorer compatibility. This patch will support the latest version of Internet Explorer (ie. IE 9). The patch is expected to be released by June 2012.

The object identification, certificate handling, Xpath creation and source coding capabilities can only be judged once the patch is released. As of now, what I can say is that it will act as another feather in HP’s cap and it will solve more industry problems.


You may also want to read –
AJAX TruClient Protocol – Tips and tricks Part I
AJAX TruClient – The next Revolution in Performance Testing domain
AJAX TruClient – Parameterization, Text Verification and Object Identification

And Jason’s review on TruClient –
HP TruClient – A Review

4 thoughts on “AJAX TruClient – Tips and Tricks Part II

  1. Hi Jason,

    If you get a chance, please see if you can try the TruClient for Silverlight based application?

    I tried but so far looks like it doesn’t support Silverlight based application.

    Do share your finding if any or if you are able to make it work.


  2. Hey, I am just starting with the Ajax trueclient, could any one tell me how to handle the if else condition there, for eg, if I want to exit from the current iteration and start a new one on find a particular text in a page, how should I do that?? or finding a particular text, should leave that transaction and iteration should stop there…..can anyone send me those things please @ my mail id [email protected]

  3. Hi ,

    I’m inputing some text box and at the last test box , when I press TAB from keyboard the correct information shows . But AJAX truClient does not capture TAB action . Can you guys help me to sortout this issue .

Leave a Reply

Your email address will not be published. Required fields are marked *