Micro Focus QTP (UFT) Forums
Reusable function. - 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: Reusable function. (/Thread-Reusable-function)



Reusable function. - webapp - 01-24-2008

Hi,

We use QTP 9.2 to test a web application at our work.
For this we need to create a script first that clears the cache & cookies on IE-6.
The script works fine when I record and playback.
I also want to use this script as a reusable script, which means before I run any script I want the cache and cookies cleared and then I want the other part of the application to run.
I have tried using Insert--> call to New Action ,but the first script opens until Tools and later it does not recognize the Internet options under it and fails.
But when I run the first script by itself it works fine.

Any help on this is greatly appreciated.

Thanks.


RE: Reusable function. - idolast - 01-25-2008

You could use "Insert->Call to Existing Action" to insert the existing Action. This is only possible if the action is declared as reusable.

But be careful: The DataTable-Sheets of the external Action and all its sub-actions will get a new name, when integrated into another test. This new name is: "Actionname [Testname]".
So if your action accesses any of the DataTable-Sheets directly using their names, you have to keep this in mind.
In order to overcome this problem you can access your datatable-sheets like this:

Code:
Set myRegExp = new RegExp
myRegExp.Global = false
myRegExp.Pattern = "NameOfThisAction"

sheetSuffix =  myRegExp.Replace(DataTable.LocalSheet.Name, "")

Now the access to the sheet:
testValue = DataTable("myColumn",  "TheAction" & sheetSuffix)