Page 1 of 1

How to validate two elements at a time?

Posted: Wed Aug 07, 2013 10:03 am
by gnm_fheinrich
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???

Re: How to validate two elements at a time?

Posted: Wed Aug 07, 2013 8:50 pm
by Ciege
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;
}

Re: How to validate two elements at a time?

Posted: Thu Aug 08, 2013 3:40 pm
by mzperix
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