Command to stop iteration

Ranorex Studio, Spy, Recorder, and Driver.
Pixi6s
Posts: 92
Joined: Tue Jun 28, 2011 8:57 pm

Command to stop iteration

Post by Pixi6s » Fri Jul 15, 2011 5:11 pm

Hello,

I have my test cases set to "continue with iteration" because generally the show must go on. I do have one case within the first code module where if it does not find the correct page, than I want the current iteration to end and the next iteration to start.

Is there a programmatic way to ask the iteration to stop in one particular instance?

I have an aside question as well. When I manually stop a run it doesn't bring up the report "so far" I find this annoying. I am in debug mode so I often don't need the entire test case to complete but I'd often like to view the log. Is this possible?

Thanks
Sierra

User avatar
slavikf
Posts: 104
Joined: Mon Sep 13, 2010 9:07 pm
Location: Toronto, Canada
Contact:

Re: Command to stop iteration

Post by slavikf » Fri Jul 15, 2011 5:40 pm

Pixi6s wrote:I have my test cases set to "continue with iteration" because generally the show must go on. I do have one case within the first code module where if it does not find the correct page, than I want the current iteration to end and the next iteration to start.

Is there a programmatic way to ask the iteration to stop in one particular instance?
What language you using? C#? VB?
What operator are you using for iteration?
When I manually stop a run it doesn't bring up the report "so far" I find this annoying. I am in debug mode so I often don't need the entire test case to complete but I'd often like to view the log. Is this possible?
Report is saved as temp file in project folder. You can open it manually

Pixi6s
Posts: 92
Joined: Tue Jun 28, 2011 8:57 pm

Re: Command to stop iteration

Post by Pixi6s » Fri Jul 15, 2011 6:06 pm

My bad, I am in Ranorex 3.0.4 and my user code is in C#.

I'm not sure what you mean by operator. I have a SQL data source that it is iterating around...
Thanks

User avatar
slavikf
Posts: 104
Joined: Mon Sep 13, 2010 9:07 pm
Location: Toronto, Canada
Contact:

Re: Command to stop iteration

Post by slavikf » Fri Jul 15, 2011 6:08 pm

Generally, you should use "break" statement.
See details at MSDN

Pixi6s
Posts: 92
Joined: Tue Jun 28, 2011 8:57 pm

Re: Command to stop iteration

Post by Pixi6s » Fri Jul 15, 2011 6:23 pm

I did try it but it didn't work because I am not actively using a loop. My testcase has a SQL data source that it is iterating around. Under that testcase I have user code modules and recording modules that it iterates through. I'd like it to continue when a validation fails, but I need it to stop when it can't find the correct product page, or all the validations fail because it's testing the wrong product.

Thanks

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Command to stop iteration

Post by Support Team » Mon Jul 18, 2011 11:31 am

Hi,
Pixi6s wrote:Is there a programmatic way to ask the iteration to stop in one particular instance?
you can do this by calling Report.Failure(String) within you user code if you know, you are not in the correct product page. Report.Failure will make your iteration stop and by selecting "Continue with iteration" for Error behavior in your Test Case settings the next iteration will be executed.

Regards,
Tobias
Support Team

Pixi6s
Posts: 92
Joined: Tue Jun 28, 2011 8:57 pm

Re: Command to stop iteration

Post by Pixi6s » Tue Jul 19, 2011 1:19 pm

I updated my report call from report.log(reportlevel.failure, str, str) to report.failure(str, str) and it did not change the behavior. The test and current iteration still continues. Am I using it wrong?

Code: Select all

        	//Determine if correct deal is being tested
        	bool bCheckID = CheckDealID(DealID);
        	if (bCheckID == false)
        	{
        		bool bExist = repo.WebDocument.CorpSideBar.RelatedDeal1BuyInfo.Exists();
        		if (bExist)
        		{
					repo.WebDocument.CorpSideBar.RelatedDeal1Buy.Click();
					bCheckID = CheckDealID(DealID);
					if (bCheckID == false)
					{
						bExist = repo.WebDocument.CorpSideBar.RelatedDeal2BuyInfo.Exists();
						if (bExist)
						{
							repo.WebDocument.CorpSideBar.RelatedDeal2Buy.Click();
							bCheckID = CheckDealID(DealID);
							if (bCheckID == false)
							{
					        	Report.Failure("Correct Deal Cannot be found");
							}
						}else{
							Report.Failure("Auto", "Correct Deal Cannot be found");
						}
					}
				}else{
        			Report.Failure("Auto", "Correct Deal Cannot be found");
        		}
        	}

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Command to stop iteration

Post by Support Team » Tue Jul 19, 2011 8:08 pm

Hi,

does your method CheckDealID work correctly?
Do you get the failure message logged within your report?
Basically a failure message makes the test case fail.

Regards,
Tobias
Support Team

Pixi6s
Posts: 92
Joined: Tue Jun 28, 2011 8:57 pm

Re: Command to stop iteration

Post by Pixi6s » Wed Jul 20, 2011 6:29 pm

Yes CheckDealID works correctly, it is very simple

Code: Select all

	    public static bool CheckDealID(string sExpectedID)
	    {
			//Check ID
			string sHref = repo.WebDocument.Corp.BuyButton.Href.ToString();
			string sDealID = Util.Util.ReturnDealIDFromURL(sHref);        	
			if (sDealID == sExpectedID)
			{
				return true;
			}else{
				return false;
			}
	    }

        public static string ReturnDealIDFromURL(string sUrl)
        {
            int x = sUrl.IndexOf("?id=") + 4;
            return sUrl.Substring(x, sUrl.Length-x);        	
        }
Yes I do get the failure message logged into my report. (see attachment)

It doesn't seem to be working in my case. the rest of the code in that usercode executes as well as the next record module starting up.
You do not have the required permissions to view the files attached to this post.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Command to stop iteration

Post by Support Team » Thu Jul 21, 2011 9:26 am

Hi,
Pixi6s wrote:It doesn't seem to be working in my case. the rest of the code in that usercode executes as well as the next record module starting up.
Sorry my colleague mixed something up. Report.Failure() logs a logical failure (e.g. test step failure) message and it doesn't abort the whole iteration. If you want to abort the whole iteration you have to throw a new exception. For example:
throw new RanorexException("text");
But please choose the exception to your abort criteria. If you validate something please use ValidationException() and so on.

Regards,
Peter
Ranorex Team

Pixi6s
Posts: 92
Joined: Tue Jun 28, 2011 8:57 pm

Re: Command to stop iteration

Post by Pixi6s » Thu Jul 21, 2011 3:10 pm

Thank you, this call does do what I need. But it doesn't seem to print out my string to the log. Do I need to report out a log string before making this call?

Code: Select all

throw new Ranorex.ValidationException("Correct Deal Cannot be found");
You do not have the required permissions to view the files attached to this post.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Command to stop iteration

Post by Support Team » Thu Jul 21, 2011 3:28 pm

Hi,

This is a bug in our Software and we will fix this with Ranorex 3.0.5.
Meanwhile please log a Report.Info() or Report.Failure() before you throw the exception.

Regards,
Peter
Ranorex Team

Pixi6s
Posts: 92
Joined: Tue Jun 28, 2011 8:57 pm

Re: Command to stop iteration

Post by Pixi6s » Fri Jul 22, 2011 4:17 pm

Thanks works well thanks

Pixi6s
Posts: 92
Joined: Tue Jun 28, 2011 8:57 pm

Re: Command to stop iteration

Post by Pixi6s » Thu Jul 28, 2011 1:38 pm

Is there a command to stop an iteration that is not a failure? I now have a case where if it's a certain type of product to skip the iteration.

Thanks

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Command to stop iteration

Post by Support Team » Thu Jul 28, 2011 2:01 pm

Pixi6s wrote:Is there a command to stop an iteration that is not a failure?
Sorry but such a functionality is not available. Just delete the iteration from your data-source and ranorex won't executed it.

Regards,
Peter
Ranorex Team