Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to create a suitable loop
#1
Solved: 11 Years, 3 Months, 3 Weeks ago Question 
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?

Regards,
Tom
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi,
Go for FOR loop and run the loop to the number of times u want.

Regards,
Sankalp
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
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?


Attached Files Image(s)
       
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
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.

Reply
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
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.

How can I avoid this problem?


Code:
DataTable.ImportSheet "C:\Programme\HP\QuickTest Professional\Tests\erzeugteAuftragsnr.xls","auftrag_erstellen",Global  <--- <--- <--- <--- <--- <---

Dim intAuftragsnr, intZeilenGesamt, intAktuelleEORI

intAuftragsnr = DataTable("erzeugte_nr",Global)
intTestnr = Right (intAuftragsnr,4)

intZeilenGesamt = DataTable.GetSheet("Action_eori_schleife").GetRowCount
msgbox intZeilenGesamt
~
~
~
Reply
#6
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi,

I doubt whether the command you are using for pulling the data from data table is correct.

It should be Datatable.value(parameter_id,sheet_id) not Datatable(parameter_id,sheet_id)

Could you revisit and let me know.

Thanks
Anil
Reply
#7
Solved: 11 Years, 3 Months, 3 Weeks ago
I checked again the online help:

Syntax
DataTable.ImportSheet(FileName, SheetSource, SheetDest

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...


Reply
#8
Solved: 11 Years, 3 Months, 3 Weeks ago
Sorry I misread your question...

Please try this: DataTable.ImportSheet "C:\Programme\HP\QuickTest Professional\Tests\erzeugteAuftragsnr.xls","auftrag_erstellen","Global"

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!

Hope this clarifies

thanks


Reply
#9
Solved: 11 Years, 3 Months, 3 Weeks ago
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.

Thanks for your help Smile

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is QTP suitable for banking apps? hulan 1 3,318 10-20-2016, 05:16 PM
Last Post: Ankur
  FOR LOOP shayk1985 1 5,301 12-13-2012, 11:35 AM
Last Post: sams001
  How to exit from a for loop silpavinod 2 9,873 10-17-2012, 12:55 AM
Last Post: agarwl.anurag
  for loop sia sharma 1 3,340 09-13-2012, 11:44 AM
Last Post: ksrikanth2k9
  Help with Loop LJENNE 1 3,187 08-10-2012, 12:32 PM
Last Post: Ankesh

Forum Jump:


Users browsing this thread: 2 Guest(s)