01-13-2012, 11:25 PM (This post was last modified: 01-13-2012, 11:27 PM by zivit_i14.)
Hy,
I'm a beginner and have the following problem:
I use a test automation, in which I log onto an application and select a file. In this file must be set and saved 20 numbers. This steps includes selecting the file, set a number and save again. In the script currently I've copied and pasted this steps 20 times. Surely I better can solve this issue with a loop.
Which loop is suitable and where do I put the 20 numbers, so that the loop can work with it?
Hi,
I tried the For Loop, but I fail in the attempt to test the script. I have set the 20 numbers in the dtLocalSheet. However when I run the test, QTP uses a different run-time table. What did I do wrong?
save and close your test.
go to your saved location and check if data has been saved properly as you want it in the default.xls or any other data file you are using.
if not correct it in there.
open your test again, it should be resolved. let us know if not.
apart from using for loop for using different data what you can do is - put all the data in global sheet and run simply without using any loop. qtp will run the same statements for number of iterations as per the data in global sheet.
The file has stored the correct numbers. And the local column is also ok in default.xls.
There seems to be a problem with the import line. If I comment out this line, QTP is working correctly. But I need this external sheet, because it is a working number, which is always regenerated.
My scriptline
DataTable.ImportSheet "C:\Programme\HP\QuickTest Professional\Tests\erzeugteAuftragsnr.xls","auftrag_erstellen",Global
The syntax should be correct. Meanwhile, it also works with the DataTable. But I can not explain where the problem was. I've restarted the program several times and checked the default.xls. In the first time, the file had multiple lines after running the test. However, it should be only one line for working number.
Except for a reboot, I have nothing changed. I can not explain...
When you use 'Global' keyword without quotes, it directly replaces your local sheet instead of the global sheet. The question is why?? I dont know the exact reason but it might be that since it is not able to find any suitable sheet with the particular name, it will replace the local sheet.. thats how import works!
I've tried with and without quotes. In both times it used a different DataTable. I've solved it another way. In the last step I imported the working number to the local DataTable. Than I changed to Global... and it works.