Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Launch n-times QTP Test with different Excel Files
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
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!
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
"TestIteration" is a built -in environment variable ....so prabhat's code can be directly reused.
We need not create this environment variable.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Files comparison using QTP santosh.msr 0 2,177 07-11-2016, 11:38 AM
Last Post: santosh.msr
  UFT taking different script execution timings while comparing 2 excel files. sudheer 0 2,351 06-26-2015, 03:28 PM
Last Post: sudheer
  QTP Should open files(say txt files) it can be n number from a folder. Shiv Y 1 2,783 12-18-2013, 01:45 AM
Last Post: mlkrqtp
  To view log files in QTP sheetal 5 16,759 10-08-2013, 02:27 PM
Last Post: Gurpreet
  "qtp.launch" throwing "class not registered" error auto_tester 0 3,149 08-13-2013, 10:52 PM
Last Post: auto_tester

Forum Jump:


Users browsing this thread: 1 Guest(s)