Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QTP Tips and Tricks
#20
(07-25-2011, 11:49 AM)rajpes Wrote: Let us share some tips and tricks we come across when working with QTP.

If you want to share a New trick,add appropriate title in the "Post Subject" after clicking on the "New Reply" link.





Setting.Add trick to use run session values in next run sessions


Suppose you want to save some values manipulated in the run session somewhere so that you would like use them for next run session, the only ways(i think) are to save them to some external files like excel or output the values to global sheet.

I just went through the topic
"Setting Testing Options During the Run Session" which explains about
Setting.Add through which we can add some key value pairs more or less same like Environment variables

If you change the user defined Environment variables(pre-defined or dynamically created) in run time,they are all lost when the run session ends as they are reset to their original values and it can throw error if you try to use some dynamically created Environment variables of the last run !


So,the trick which i found is,
Just save your values in the form of 'key value pair' to Setting.Add "key","value"
which once created can be accessed in any run session thereafter.

Example of how to use it.
Code:
If Not Setting.Exists("IterNum") then
Setting.Add "IterNum", 1 'create "IterNum" and assign to 1
else
msgbox Setting.Item("IterNum") 'Use it or modify it as written below
Setting.Item("IterNum")=Setting.Item("IterNum")+1 ' modify "IterNum"
end if
Now run this and see, first time you run, it will create a new setting item and next time you run, the message box promt will show the value.

Isn't it cool?Shy

Note:These values will not be saved with the test after you close the test or open some other test(or create a new test)l!

Hi,
Nice iniciative.
The method you posted is something like Global Dictionary, where we can add values on the basis of keys.

Please clariffy my doubt.

Regards,
Sankalp
Reply


Messages In This Thread
QTP Tips and Tricks - by rajpes - 07-25-2011, 11:49 AM
How to open and edit multiple scripts - by rajpes - 07-25-2011, 03:48 PM
RE: QTP Tips and Tricks - by Ankur - 07-25-2011, 04:02 PM
Simplest way to open a webpage - by rajpes - 07-26-2011, 03:24 PM
VBScript to print a pattern - by rajpes - 07-27-2011, 04:05 PM
RE: QTP Tips and Tricks - by nakulgupta18 - 03-07-2014, 04:05 AM
RE: VBScript to print a pattern - by ashitroy1991 - 08-24-2017, 12:46 PM
weblist index tip - by rajpes - 07-29-2011, 11:14 PM
RE: QTP Tips and Tricks - by gaveyom - 08-29-2011, 11:19 AM
@gaveyom - by rajpes - 09-21-2011, 05:11 PM
Initializing a counter in Do loop - by rajpes - 09-21-2011, 06:15 PM
worksheets or sheets - by rajpes - 09-22-2011, 12:13 PM
ComboBox items into array - by rajpes - 09-23-2011, 03:49 PM
DataTable.Import/ImportSheet - by rajpes - 09-25-2011, 12:29 PM
How to know the password - by rajpes - 10-11-2011, 11:06 AM
RE: QTP Tips and Tricks - by sshukla12 - 12-21-2011, 10:43 AM
RE: QTP Tips and Tricks - by Sathiya - 12-21-2011, 05:54 PM
RE: QTP Tips and Tricks - by rajpes - 01-30-2012, 07:51 PM
RE: QTP Tips and Tricks - by rajpes - 02-02-2012, 04:59 PM
RE: QTP Tips and Tricks - by sshukla12 - 03-02-2012, 02:37 PM
Using "Navigate and Learn" option - by rajpes - 02-06-2012, 07:45 PM
RE: Using "Navigate and Learn" option - by Dhiman - 02-15-2012, 10:02 PM
RE: Using "Navigate and Learn" option - by rajpes - 03-02-2012, 01:42 PM

Forum Jump:


Users browsing this thread: 8 Guest(s)