Ignore Steps

Ask general questions here.
riccardo
Posts: 30
Joined: Wed Apr 28, 2010 10:37 pm

Ignore Steps

Post by riccardo » Thu Apr 28, 2011 4:53 pm

I have an Iteration which checks for Values (Error Messages) on a popup window

Now the error messages will be thrown all on the same step (site) in the workflow, except in one single case it will be thrown on another (earlier) step. I would like to avoid writing a recording for this single problem, but would rather like to implement a function which checks on this specific site if the error message appears or not.

Meaning:

1. Step
2. Step
3. Step (here I would like to check if the error message is showing up, if yes validate it and ignore the next steps... and continue with the next Testcase in the CSV)
4. Step
5. Step (normal validation)

I do have a variable in my CSV which tells me if a validation shows up in Step 3, so this can be checked. But I do not know how I could ignore the next steps, set the iteration to passed / failed and continue with the iteration.

Any idea?

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

Re: Ignore Steps

Post by Ciege » Thu Apr 28, 2011 5:02 pm

Are you using recordings only or are do you have any user code implemented?

If you have user code and are comfortable writing your own code you only really need to add an If statement that checks the message appears and if so do A else do B.
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...

riccardo
Posts: 30
Joined: Wed Apr 28, 2010 10:37 pm

Re: Ignore Steps

Post by riccardo » Thu Apr 28, 2011 5:08 pm

I do have user code implemented, but no clue how to ignore the next steps

would a Report.Successful do that?

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

Re: Ignore Steps

Post by Ciege » Thu Apr 28, 2011 5:14 pm

Well, can you share your part of code that looks for the message? That way I can help tailor my response to your particular scenario.

In general terms, when you search for the error message, I assume using a FindSingle for the message form, you can check if the Ranorex.Form value is null. If it is null then the form was not found, if the Ranorex.Form has a value then the message form was found.
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...

riccardo
Posts: 30
Joined: Wed Apr 28, 2010 10:37 pm

Re: Ignore Steps

Post by riccardo » Thu Apr 28, 2011 5:25 pm

I have a usermethod called validatePersonError which I do call when the iteration is on that step

Variables:
checkpoint (contains the location where the error get's thrown, e.g "Person", "Services")
s_errormessage (contains the expected errormessage)

Code: Select all

public void validatePersonError()
{
    if (checkpoint.equals("Person"))
    {
         // This routine validates the given error message on the popup and closes the popup
         //  If the validation fails, the next iteration will be started
         Helper.validateError.validateMessage(s_errormessage);
         
         // Now if this point has been reached, this means the validation was successfull and  here I would
         // like to force this testcase to be finished successfully and go ahead with the next iteration

    }
}


I hope it is enough clear what I mean.

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

Re: Ignore Steps

Post by Ciege » Thu Apr 28, 2011 5:43 pm

So you can change your method from void to bool and return a result back to the method caller. Then the method caller can test that result and determine if it should continue with the next step or not.

I made some pseudo code changes below to help you on your way.

Code: Select all

//From your main method call the validation method
bool boolResult = validatePersonError();

//Then test the result of the validation method and react accordingly
if boolResult = true
   Do A
else
   Do B

public bool validatePersonError()
{
    if (checkpoint.equals("Person"))
    {
         // This routine validates the given error message on the popup and closes the popup
         //  If the validation fails, the next iteration will be started
         Helper.validateError.validateMessage(s_errormessage);
         
         // Now if this point has been reached, this means the validation was successfull and  here I would
         // like to force this testcase to be finished successfully and go ahead with the next iteration
HERE ->         If helper = pass return true else return false
 
    }
}

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...

riccardo
Posts: 30
Joined: Wed Apr 28, 2010 10:37 pm

Re: Ignore Steps

Post by riccardo » Thu Apr 28, 2011 7:23 pm

Okay got that

What I am looking for is exactely the thing you called "Do A" or "Do B"
How do I force a test to be finished, like kind of a Testcase.finish ?

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

Re: Ignore Steps

Post by Ciege » Thu Apr 28, 2011 7:38 pm

If you steps are called from the Main method you can just Return from Main and the code will exit.

Code: Select all

static void Main(string[] args)
{
    boolResult = StartTest1()
      If boolResult = false
        return
    boolResult = StartTest2()
      If boolResult = false
        return
    boolResult = StartTest3()
      If boolResult = false
        return
etc...
}

public bool StartTest1 ()
{
    bool boolResult = validatePersonError();
    if boolResult = true
        return true
    else
        return false
}

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...

riccardo
Posts: 30
Joined: Wed Apr 28, 2010 10:37 pm

Re: Ignore Steps

Post by riccardo » Fri Apr 29, 2011 7:43 am

Okay I see what you mean

So but do you know the command which just stops the actual testcase?

I do have only some steps as usercode, the rest is in the recording itself. I would need to change the testcase so everything is in user code, then this would be quite easy to handle...
But if I could force it only with a command I would prefer this solution

riccardo
Posts: 30
Joined: Wed Apr 28, 2010 10:37 pm

Re: Ignore Steps

Post by riccardo » Fri Apr 29, 2011 3:23 pm

Okay I solved it by keeping the recording, but calling one single user code

In this user code I do call the other steps and handle it with an if statement... not the way I wanted it to have, but the way it works :mrgreen:

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

Re: Ignore Steps

Post by Ciege » Fri Apr 29, 2011 3:48 pm

Well, you got it to work, thats good!

All of my automation is custom code. I don't use the recorder at all. It has far more flexibility that way, but is also a bit more difficult to get everything up and running initially.

My suggestion is to eventually move as much as you can out of record/playback and into custom user code. It releases you from any limitations that are set by using the record/playback system.

Good luck!
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...