Micro Focus QTP (UFT) Forums
Storing dynamic data at run time - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Storing dynamic data at run time (/Thread-Storing-dynamic-data-at-run-time)



Storing dynamic data at run time - Rupesh - 01-12-2008

Hi Ankur,

We have recently started using QTP for testing of our web sites. We have different actions to define data for the required fields on the web site. There are certain scenarios where data can only be identified at run time. We need to capture this data and store some where for verification at later point.

Currently we are adding a new data sheet at run time. Run time data is stored in the data sheet by adding parameters at run time. Since the data sheet is added by main action in the script it is accessible by all reusable actions. Since data is defined at run time; I am afraid that it will exceed the maximum possible columns (256) in data sheet and will fail some time (based on entries in database).

Can you suggest any approach to store run time data in any other format and be able to pass this information to other actions for later use and modifications?

Thanks,
Rupesh


RE: Storing dynamic data at run time - Ankur - 01-12-2008

Are you sure you have 256( or more) fields to feed data, at run time?

If at all thats the case, make use of environment variable. Environment variable are visible throughout the run and can be checked at any point.


RE: Storing dynamic data at run time - Rupesh - 01-13-2008

Thanks Ankur, that was quite helpful.

For others who look at this thread, here is the code that I am using to add environment variables at run time to define the data at run time. Ankur if you a have easy way of doing this, please post.

code goes like this:
"
Code:
'Define data
On error resume next
temp_val = environment.Value("FName")
If err.number <> 0 Then
    environment.Value("FName") = "Rupesh"
End If

On error resume next
temp_val = environment.Value("LName")
If err.number <> 0 Then
    environment.Value("LName") = "Mishra"
End If

'Display recently define data
On error resume next
MsgBox "Name is : "  & environment.Value("FName") & " " & environment.Value("LName")
If err.number <> 0 Then
    MsgBox "Parameter FName not defined"
End If

On error resume next
MsgBox "Date of Birth : " & environment.Value("DOB")
If err.number <> 0 Then
    MsgBox "Parameter DOB not defined"
End If

"

This code will display two message boxes; first one with text "Name is : Rupesh Mishra" and second one "Parameter DOB not defined"

Thanks
Rupesh


RE: Storing dynamic data at run time - Rupesh - 01-15-2008

OK... here is next problem.

I stored run time data in different environment variables. I do this in every iteration. Since environment variables do not reset till the script is running I am facing problems. I need to reset environment for each of the iteration.

Is there a way to

1.) Identify how many environment variables are defined
2.) Find the names of these environment variables
3.) Delete them

QTP GUI allows deleting User defined internal variables. There should be a way to do it programmatically. If you know please post.

Thannks


RE: Storing dynamic data at run time - Ankur - 01-16-2008

You can use File > Test Settings > Generate Script to get this done programmatically ( First make sure that you define atleast one "userdefined" variable under Environment variable settings) ---of course you need to tweak the code to make it work for you.

Otherwise you can do a workaround also,
Overwrite the environment variable and where overwriting is not taking place make them blank.


RE: Storing dynamic data at run time - kishoreinchennai - 07-29-2008

Hi

1)Why not use a Simple flat(text) file and write all your values
The classic comma separated format

2)Why use colums in a excel sheet use the rows, rows are not limited.

Define a excel object and write it in the rows without importing
we can USE colum a for variable name colum b for value....
regards
Kishore