avoids some of the records while running
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
avoids some of the records while running
any suggestions how to fix this,
while running the script it avoids some records and stops the loop even though I have set of records with dates.
grd.ClickItem("Edit");
for(i=0;i<=Grid.wRowCount-1;i++)
{
var dateString = Grid.wValue(i, "Created Date");
if (aqString.Find(dateString, FormatStr, 0, false) != -1) {
Delay(1000)
Grid.ClickCell(i, "Created Date");
Control.ClickItem("Delete");
Form5.Click(105, 12);
Form5.SimpleButton.ClickButton();
Delay(1000);
//Log.Message(FormatStr + "FormatStr" + "' was found in string '" + "dateString")
var foundRow = i;
//break;
}
else Log.Message(" no date found")
}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As you delete rows, the row count changes... and the index of each row changes. So, let's say you have a date row at row 5 and another one at row 6. So, you find the one at row 5... you delete it... now the one at row 6 is now row 5. but you've already iterated through row 5 so whatever is in row 5 now gets skipped. So, you are dealing with a grid that is changing length as you are looping through it.
You will probably also get another error where you may try to access a row that no longer exists when you get to the end.
So... instead of a for loop...you're going to need to do something entirely different. You're going to need to do (again, pseudo-code) something like:
var foundRow = Grid.FindRow('Created Date') //I think this code you already know how to use. while (foundRow != -1) { //Assuming foundRow returns -1 if it doesn't find something //Do your stuff where you click the cell, delete, etc. //repeat the findRow foundRow = Grid.FindRow('Created Date') }
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thansk Alot martin. I think thats what happening.can you please check with while loop: i am getting error: grid column index 112 is out of bounds
var i=Grid.wRowCount-1;
var Foundrow=Grid.FindRow(i,"Created date");
While(Foundrow!=-1)
{
var dateString = Grid.wValue(i, "Created Date");
if (aqString.Find(dateString, FormatStr, 0, false) != -1) {
Grid.ClickCell(i, "Created Date");
dockedBarControl.ClickItem("Delete");
Form5.Click(105, 12);
Form5.SimpleButton.ClickButton();
Foundrow=Grid.FindRow(i,"Created Date")
}
else log.Error(" no row Found")
}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First parameter of FindRow is the Column indicator. So, you can't use "i" in the first parameter of FindRow.
You are going to need to write some VERY fancy code find the first instance of the desired date, reset the index of the loop, and repeat until all required dates are found. I MIGHT be a for loop after all... but I'm thinking it might be a while loop.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
grd.ClickItem("Edit"); var continueLoop = true; var foundRow; while(continueLoop){ foundRow = -1; for(i=0;i<=Grid.wRowCount-1;i++){ // Loop through to find the first desired date var dateString = Grid.wValue(i, "Created Date"); foundRow = aqString.Find(dateString, FormatStr, 0, false) // if we find one, break out of the for loop. If we don't, we continue the for loop. foundRow will be -1 if nothing is found if ( foundRow != -1) { break } } //if foundRow is not -1, then we do our delete stuff and continue the while loop if (foundRow != -1) { Delay(1000) Grid.ClickCell(i, "Created Date"); Control.ClickItem("Delete"); Form5.Click(105, 12); Form5.SimpleButton.ClickButton(); Delay(1000); continueLoop = true; } //if we get out of the for loop and foundRow is still -1, indicate to no longer continue the while loop else continueLoop = false; }
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
