This is a migrated thread and some comments may be shown as answers.

While Loop Error

7 Answers 152 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sebastian
Top achievements
Rank 1
Sebastian asked on 13 Jul 2011, 05:22 PM

I have a While Loop step that runs just fine.
It verifies that an item is visible and then runs the loop steps if it is true.
It shows an error after the test is over even when I see it run correctly.
The error message says Unable to find element.
Everything inside the loop runs just fine but after the test is done all the steps in the loop show triangles on them as if they never ran.
I'm thinking the While Loop step is showing an error  when the verify element is false.
This is expected to happen after one to five or how even many loops are needed to get the desired results.
I want the verify element step to be false at some point when the expected result is achieved.
I would think that the while loop would at some point end without an error???

 

I'm running Test Studio version 2011.1.624.0 on Windows 7 Ultimate 64bit

with IE8 version 8.0.7601.17514

7 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 13 Jul 2011, 06:21 PM
Hi Sebastian,

I suspect you are not receiving the error because the Verify condition is finally false (not visible), but because the element used for the Verify condition cannot be found on the page once the condition is false.

In other words, the element used for the Verify condition needs to exist for every loop so it can always be located and verified. It sounds like once the element is no longer visible, your app is in a different state (or on a different page), and the element can no longer be found for the loop to exit cleanly.

See a simple demo here.

Kind regards,
Anthony
the Telerik team
Register today for a live 'What's New in Test Studio R1 2011 SP2' event on Tuesday, July 19 at 2pm EST!

Have you looked at the new Online User Guide for Telerik Test Studio?
0
Sebastian
Top achievements
Rank 1
answered on 13 Jul 2011, 06:33 PM
In the Video no error happens after the test hits 4.
What do you recomed I do for my operation to not get an error???
0
Anthony
Telerik team
answered on 13 Jul 2011, 08:40 PM
Hello Sebastian,

The video is a simple example of how the element used to perform the verification, the numerical result, is static and the page never changes.

I suspect your page does change, or is in a different state, and the element used by the verification cannot be found at the point where the loop attempts to exit.

I recommend you craft a more reliable verification and attach it to the While loop. Based it on an element that is consistent across your app.

Greetings,
Anthony
the Telerik team
Register today for a live 'What's New in Test Studio R1 2011 SP2' event on Tuesday, July 19 at 2pm EST!

Have you looked at the new Online User Guide for Telerik Test Studio?
0
Sebastian
Top achievements
Rank 1
answered on 13 Jul 2011, 08:43 PM
What I'm doing is clicking on delete on every element that has delete on it until they are all gone.
In the end there are no more deletes to be see on the screen.
I want them to be gone and then move on with the test.
0
Anthony
Telerik team
answered on 13 Jul 2011, 10:26 PM
Hi Sebastian,

It sounds like the While loop is using one of these "deleted" elements for its verification. Once they are all gone, that element no longer exists, so Test Studio cannot find it to make its comparison and properly exit the loop. Thus you receive the "Unable to find element" error.

Perhaps there is a different element to base the While loop's verification on. Is there a field that displays the number of currently visible items? If so, like the demo video, you could craft the verification to 'InnerText' 'NotContain' '0'. So, while that count number is not 0, the loop continues executing (deleting the items) until the count is 0, and then it exits.

Without seeing your app first-hand I can only speculate how to alter your test to make it run properly. If you continue to have difficulty, please grant me remote access and attach a copy of your test in .zip format.

Regards,
Anthony
the Telerik team
Register today for a live 'What's New in Test Studio R1 2011 SP2' event on Tuesday, July 19 at 2pm EST!

Have you looked at the new Online User Guide for Telerik Test Studio?
0
Sebastian
Top achievements
Rank 1
answered on 13 Jul 2011, 11:22 PM
Will it work on any verify once the item is gone?
If not I can't use the While Loop for this.
I will need a coded step to get the job done.
If Test Studio had a GoTo Step I could do a lot of other things.
I could use an IfThenElse and a GoTo to do this.
0
Anthony
Telerik team
answered on 14 Jul 2011, 03:11 PM
Hello Sebastian,

The Verification that your While loop is based on needs to be built on an element that exists during and after the loop executes. It seems you are currently verifying one of the items to be deleted, so once it's gone Test Studio cannot locate the element to verify it is no longer visible and properly exit the loop.

If you wish to perform more complicated steps that cannot be recorded through the user interface, take advantage of our Script Step feature.

Best wishes,
Anthony
the Telerik team
Register today for a live 'What's New in Test Studio R1 2011 SP2' event on Tuesday, July 19 at 2pm EST!

Have you looked at the new Online User Guide for Telerik Test Studio?
Tags
General Discussions
Asked by
Sebastian
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Sebastian
Top achievements
Rank 1
Share this question
or