Micro Focus QTP (UFT) Forums
Launch n-times QTP Test with different Excel Files - 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: Launch n-times QTP Test with different Excel Files (/Thread-Launch-n-times-QTP-Test-with-different-Excel-Files)



Launch n-times QTP Test with different Excel Files - nacchio - 11-03-2011

Hi,

I have to Excel files: File1.xls and File2.xls. I want to launch my QTP Test 2-times; the first time the test loads File1.xls, the second time loads File2.xls.
I want that this operation has automatized in a vbscript. The simplest solution, I think, is generate the script and the first put this code line

App.Test.Settings.Resources.DataTablePath = "C:\File1.xls"

and the second time this line

App.Test.Settings.Resources.DataTablePath = "C:\File2.xls"


Exist other solutions?


Thanks in advance

Andrea


RE: Launch n-times QTP Test with different Excel Files - PrabhatN - 11-07-2011

Hi Andrea,

You can make use of the environment variable "TestIteration". You can write the code below:

Code:
If Environment("TestIteration") = 1 Then
    DataTable.Import("C:\File1.xls")
    Else
    DataTable.Import("C:\File2.xls")
End If

Hope this helps!


RE: Launch n-times QTP Test with different Excel Files - Nandana Vijay Kumar - 11-08-2011

Hi Andrea,

Prabhat's solution is good. But if you find it difficult to create environment variables you can us a simplet for loop.
Please refer the below code:

Code:
For i = 1 to 2
  if i = 1 then
     DataTable.Import("C:\File1.xls")
  else
     DataTable.Import("C:\File2.xls")
  end if
Next

Thanks,
Nandana


RE: Launch n-times QTP Test with different Excel Files - ravi.gajul - 11-08-2011

"TestIteration" is a built -in environment variable ....so prabhat's code can be directly reused.
We need not create this environment variable.