Highlighted
Regular Contributor.. Regular Contributor..
Regular Contributor..
295 views

Reading data from Excel in Truclient during execution

Hello,

I am using Loadrunner 12.57 and I have a requirement to read data that includes UserId & Password from excel sheet during Runtime. Currently I am creating parameters and passing them in my truclient script. Is there a way i can read data from excel sheet during test execution?

Thanks in Advance,

Jessie.

0 Likes
7 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Reading data from Excel in Truclient during execution

Hi @Jass_QA,

There is no built-in support in TruClient to read data from Excel sheet.

There is a way to do it, although it's not an easy way. Three steps,

  1. Create a DLL, implement Excel accessing logic in it, and expose APIs.
  2. In LoadRunner, define C functions in C-functions.c in Extra Files. In these C functions, load the DLL by using lr_load_dll, using the APIs exposed in that DLL.
  3. Call C functions defined in C-functions.c by using TC.evalC from TruClient side.

For step 2 and step 3, this answer is helpful.

0 Likes
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: Reading data from Excel in Truclient during execution

@Jass_QA, another option for step 1 is to register your excel sheet as an ODBC data source and connect to this data source via LR database functions. Draw back is that you need to maintain this ODBC data source definition on each of your systems that needs to execute your script (tip you might extract an registry dump and import it on other systems).

You still have to follow the steps 2 and 3 of @Alex Zhou to complete this approach. In step 2 you need to setup the connection to your defined data source.

Signature:
Reward community members who take time to respond and help.
0 Likes
Highlighted
Trusted Contributor.. Trusted Contributor..
Trusted Contributor..

Re: Reading data from Excel in Truclient during execution

Just an idea: Why do you use excel, when TruClient nearly works perfect with VT-Servers?

0 Likes
Highlighted
Regular Contributor.. Regular Contributor..
Regular Contributor..

Re: Reading data from Excel in Truclient during execution

Thanks Alex for your response. I am not that expert in Truclient, so i will continue to use the Parameters function.
0 Likes
Highlighted
Regular Contributor.. Regular Contributor..
Regular Contributor..

Re: Reading data from Excel in Truclient during execution

Thank you for your response.
0 Likes
Highlighted
Regular Contributor.. Regular Contributor..
Regular Contributor..

Re: Reading data from Excel in Truclient during execution

I am ok with the parameters function and it's working perfectly for me. Our Development team suggested this idea and my manager asked me to explore it, if there is an easy way since we don't have VT-servers configured in our environment.
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Reading data from Excel in Truclient during execution

Hi @Jass_QA ,

If your project has big size of data source in the excel, I would suggest using VTS instead of parameter functions, VTS is a lite weight database that provided by LoadRunner, comparing to Parameter functionality, VTS is more strong function to deal with big size data, you can easily install VTS from LoadRunner setup,  then save your existing excel to CSV format, and import the CSV to your VTS server, in this way, all your data will be migrated to VTS server. Next, you can use TruClient api to manipulate with the data in VTS.

TruClient provides many build-in VTS apis to manipulate this database, see more from:

https://admhelp.microfocus.com/tc/en/latest/Content/TruClient/procedures/_tc_t_how_to_use_VTS.htm?Highlight=VTS

https://admhelp.microfocus.com/tc/en/latest/Content/TruClient/reference/functions.htm?Highlight=VTS

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.