Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
For loop after couple of If then else statements
#1
Hi
I am trying to use for loop in the middle of the code and is not working. The way I wrote is as follows
[statements to execute - 1st set]
For i = 1 To 3
[statements to execute - 2nd set]
Next
In the above situation the loop is not getting executed at all. 1st set of statements are executed 3 times.
So Changed it to
Dim i
[statements to execute - 1st set]
For i = 1 To 3
[statements to execute - 2nd set]
Next
Now there are 3 sets of "1st statement executes and then the 2nd statement is executed 3 times" (that means 3 times this path).
The 1st statement has 9 blocks of if then end if statements.
Can any one help me here pelase???
Reply
#2
If your 1set is not suppose to repeat (ie, no for or while loops), maybe your action run properties are set to run "all rows" of your datasheet. even if the datasheet looks blank, it can cause a loop for each row.

Without seeing your actual code, it is difficult to see a reason for this behavior.

Hope this helps.
Reply
#3
Here is the code - Thanks for looking into this!
Code:
Dim i If Browser("x").Page("y").WebEdit("a").GetROProperty ("Disabled") = False Then Reporter.ReportEvent micPass, "a", "a Enabled" Else Reporter.ReportEvent micFail, "a", "a Enabled" End If If Browser("x").Page("y").WebEdit("b"). GetROProperty("Disabled") = False Then Reporter.ReportEvent micPass, "b", "b Enabled" Else Reporter.ReportEvent micFail, "b", "b Enabled" End If If Browser("x").Page("y").WebEdit("c").GetROProperty("Disabled") = False Then Reporter.ReportEvent micPass, "c", "c Enabled" Else Reporter.ReportEvent micFail, "c", "c Enabled" End If Browser("x").Page("y").WebEdit("d").GetROProperty("Enabled") = False Then Reporter.ReportEvent micPass, "d", "d Disabled" Else Reporter.ReportEvent micFail, "d", "d Disabled" End If If Browser("x").Page("y").WebEdit("e").GetROProperty("Disabled") = False Then Reporter.ReportEvent micPass, "e", "e Enabled" Else Reporter.ReportEvent micFail, "e", "e Enabled" End If For i = 1 To 3 Browser("x").Page("y").WebEdit("a").Set DataTable("a", dtGlobalSheet) Browser("x").Page("y").WebEdit("a").Set DataTable("b", dtGlobalSheet) Browser("x").Page("y").WebEdit("a").Set DataTable("c", dtGlobalSheet) Browser("x").Page("y").WebEdit("a").Set DataTable("d", dtGlobalSheet) Browser("x").Page("y").WebEdit("a").Set DataTable("e", dtGlobalSheet) Browser("x").Page("y").WebElement("Search").Click Next
Reply
#4
did you check your "Action Call Properties"? You are using datasheets and you are probably set to "run all rows" instead of "one iteration". If you are set to "all rows" you will progressively run more and more iterations as your data sheet grows.

You don't seem to be changing rows on your datasheet. Do you mean for the For loop to only read the same row for values 3 times?

That is the only thing I can see that would cause this behavior. your code looks fine.
Reply
#5
Checked Action Call Properties and here are the results: With one iteration selected - The first row is being executed 3 times and not going to next two rows. If I select from row 1 - 3 - for one cycle, the first row in the data table is getting executed 3 times so 3 iterarions means 9 executions!!!
Not sure where I am going wrong??? Smile)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Infinit loop Suma Parimal 1 3,257 05-29-2014, 01:22 PM
Last Post: basanth27
  Exit Do loop shipu 1 5,325 12-20-2013, 06:33 AM
Last Post: basanth27
Smile Infinite FOR loop issue Sivapratha 3 5,140 04-01-2013, 09:44 AM
Last Post: basanth27
  embedded if statements folker 1 3,159 11-04-2011, 11:16 AM
Last Post: Ankesh
  Do Until loop returning failure mitch 0 3,905 05-27-2011, 12:20 AM
Last Post: mitch

Forum Jump:


Users browsing this thread: 1 Guest(s)