How to validate two elements at a time?

Class library usage, coding and language questions.
gnm_fheinrich
Posts: 12
Joined: Thu Jul 11, 2013 10:47 am

How to validate two elements at a time?

Post by gnm_fheinrich » Wed Aug 07, 2013 10:03 am

Hi!

In my TestSuite I validate elements. I want to know if an error-element ist found or if a success-element is found.

The negative is that i need to check one item before i can check the other item... So if i start checking if there is an error and there is no error: I wait e.g. 30 seconds. But in this time i want to recognize that there is a succes-element. So the application doesnt need to check the error-element further.

How to solve this???

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: How to validate two elements at a time?

Post by Ciege » Wed Aug 07, 2013 8:50 pm

You can write a while loop that checks for each element and continue looping until one element is found. Something like this pseudo code...

Code: Select all

boolErrorFound = false;
boolSuccesFound = false;
while (boolErrorFound = false and boolSuccessFound = false)
{
boolErrorFound = check for error with a timeout of a few seconds;
boolSuccesFound = check for success with a timeout of a few seconds;
}
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

mzperix
Posts: 137
Joined: Fri Apr 06, 2012 12:19 pm

Re: How to validate two elements at a time?

Post by mzperix » Thu Aug 08, 2013 3:40 pm

Hi,

Do you always know whether the result is error or success?

If you don't know which one comes up, then I recommend Ciege's solution.

On the other hand, if you know which element to expect, and which one not:
Create two separate recording module which checks them in the correct phase (one of them checks for the error element, the other one for the success element).
Then use the proper module in the right place.

I use this method, when I am creating positive-negative tests on one function. When I fill a form with good data, then I will look for the success element present and the error element not present, so I use that recording module. When I fill a form with bad data, then I will look for the error element present and the success element npt present - so I use the other recording module.

A fairly simple, other solution would be to redice the timeout factor on those elements, so you don't need to wait out the 30s. But I don't recommend this, since this way the log always fails on this test case and you always have to check whether it is a false alarm or not.

Regards,
Zoltan