Scripting Citrix 7.x Storefront with LoadRunner/VuGen
Posted on Sep, 2018 by Tony Gartrell
For all LoadRunner users who work with Citrix deployed applications, it is important to note that there have been major changes to the Citrix 7.x architecture which will directly impacts how LoadRunner scripts are created. One of the big changes is that Citrix 7.x no longer uses ICA files to connect to the server. Instead, the ICA information is generated on the fly and is only usable for a short period of time. Additionally, with the addition of the Citrix Storefront, the login and published app selection is HTML only.
Below are some helpful tips to help you avoid any pitfalls when using LoadRunner against Citrix 7.x.
License Considerations
Before you start scripting, you’ll need to make sure you have the correct licenses to run the script. You must use the dual protocol of Citrix ICA and Web – HTTP/HTML. This means you need both, Remote Access bundle plus Web & Multimedia or Web 2.0, to support your test. You’ll also need to make sure you have enough user licenses for both protocols as you will be using double the Vuser licenses. e.g. if you are running a 100-user test, you will using 100 licenses of the remote access protocol and 100 licenses of the Web – HTTP/HTML protocol
Windowless Mode
Citrix has for a long time used seamless windows, aka windowless mode. Unfortunately, the LoadRunner tool does not support windowless mode. In the past, when using an ICA file, it was easy to turn this off and set your resolution. That is no longer an option in the new Citrix environment. You have to turnoff seamless widows either on the Server or the client side to be able to record a script.
Server-Side Change
You can disable seamless windows on the Citrix server side. One problem with this is that it will affect all applications deployed on that server which you may not want. Talk to your Citrix Server Admin to do this, the admin may have to make some changes to the default.ica to implement that.
Client-Side Change
Luckily there is a way to change this setting on the client side. To do this you have to update the VuGen bbhook.ini file. This file is in your LoadRunner\VuGen installation directory under the config folder. Under General there is a line that has SupressCitrixOcxEnabled=false, change this to true. This turns off the Citrix ActiveX control when launched via VuGen which allows for seamless windows.
Enabling Citrix API
The next step is to make sure the Citrix API is enabled in the registry. There is a registry file located in the VuGen installation folder under the dat folder called Enable_Citrix_API.reg. If you are running a 64-bit OS it is very important that you update the file from HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\ to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Citrix\
Recording the Script
Once all the above settings are done, you can record the script. As mentioned in the licensing section be sure to record the script using the dual protocol of Citrix ICA and Web -HTTP/HTML. You can no longer just use Citrix ICA with an ICA file.
Record the login; a lot of companies may use SSO for their Storefront, if possible switch to the non-SSO login.
Script Playback
Adding Web Headers
Three headers are required to play back your script correctly. Make sure these are in your script. VuGen may or may not add these headers depending on the version of VuGen you are using.
These two should be near the start of your script, usually before the Configuration request.
web_add_auto_header("X-Citrix-IsUsingHTTPS", "Yes"); web_add_auto_header("X-Requested-With", "XMLHttpRequest");
This following needs to be after your Configuration step.
web_add_auto_header("Csrf-Token", "{c_csrftoken}");
You’ll need to correlate the Csrf-Token which is covered in the next section.
Correlation
Two values are required correlation before you can replay the script. They are the ‘CsrfToken’ and ‘GetLaunchStatus’. The ‘CsrfToken’ can be auto correlated via Design Studio or by using the Citrix_XenApp auto correlation rule for CsrfToken in your recording options. The other, GetLaunchStatus, will have to be manually correlated.
- CsrfToken
To manually correlate this step, add the following correlation statement before the Configuration step:
web_reg_save_param_ex( "ParamName=c_csrftoken", "LB/IC=CsrfToken=", "RB/IC=;", SEARCH_FILTERS, "Scope=Cookies", LAST); web_custom_request("Configuration", "URL=https://myapps.host.com/Citrix/MYAPPSWeb/Home/Configuration", …
Using a find a replace, you should replace it in the web_add_auto_header and ctrx_nfuse_connect.
- GetLaunchStatus
This one must be manually correlated since it may not be picked up with Design Studio. Add this before the second list step. You must update the Published App Name to the name of your published app. You can get the full name by doing a quick search in your Code Generation and search for the GetLaunchStatus number you are correlating.
web_reg_save_param_ex( "ParamName=c_launchica", "LB/IC=\"id\":\"Published App Name\",\"launchstatusurl\":\"Resources\\/GetLaunchStatus\\/", "RB/IC=\"", SEARCH_FILTERS, "Scope=Body", LAST); web_submit_data("List_2", "Action=https://myapps.host.com/Citrix/MYAPPSWeb/Resources/List", …
Again, do a find and a replace on it, you should replace it in the ctrx_nfuse_connect and possibly on the GetLaunchStatus request.
Lastly you should parameterize the launchID. The launchID is just a UNIX timestamp and you can use the web_save_timestamp_parm for this.
web_save_timestamp_param("c_launchid", LAST);
Your ctrx_nfuse_connect statement should now look something like this:
ctrx_nfuse_connect("https://myapps.host.com/Citrix/MYAPPSWeb/Resources/LaunchIca/{c_launchica}.ica?CsrfToken={c_csrftoken}&IsUsingHttps=Yes&launchId={c_launchid}", CTRX_LAST);
Playback Issues
If you are trying to play back the script and getting a failed to initialize extension CitrixClientImpl.dll error, you can resolve the issue by making the following change. Edit the default.cfg file of the script you are getting the error with. Remove the line that says “Window=As Recorded”. Save the file and try running the script again.
I would also like to thank Scott Moore for his contributions to this article.
Hope this article is helpful. As always, feel free to leave your feedback or comments. Happy Scripting!