Go to next step or teadrown

Best practices, code snippets for common functionality, examples, and guidelines.
yaro2o
Posts: 51
Joined: Mon Jan 29, 2018 11:19 am

Go to next step or teadrown

Post by yaro2o » Mon Feb 19, 2018 10:34 am

Hi, I have a question, I have a code that is waiting for the printout, the time is set to 10h but in the course of a pop-up error popupwatcher will detect it and close but how to make the code to finish the step and go to the next or to the teardown?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3921
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Go to next step or teadrown

Post by odklizec » Mon Feb 19, 2018 11:26 am

Hi, sadly this is not yet possible from popupwatcher. At least not directly. Your only hope (if you know where exactly the popup window might appear), is to use workaround, as described here:
https://www.ranorex.com/forum/command-t ... tml#p15846
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

yaro2o
Posts: 51
Joined: Mon Jan 29, 2018 11:19 am

Re: Go to next step or teadrown

Post by yaro2o » Mon Feb 19, 2018 12:18 pm

Sry but I have no idea how to do it :( I understand that the level popuupwatcher i will not jump to the next step ;/

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3921
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Go to next step or teadrown

Post by odklizec » Mon Feb 19, 2018 12:31 pm

Well, I'm afraid that without seeing your AUT and test solution, there is not much anyone here can do or suggest? Could you please share the AUT or at least some kind of "hello world" app, simulating your problem?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

yaro2o
Posts: 51
Joined: Mon Jan 29, 2018 11:19 am

Re: Go to next step or teadrown

Post by yaro2o » Mon Feb 19, 2018 1:02 pm

I have this method

Code: Select all

[UserCodeMethod]
    	public static void CzekajNaWydruk()
    	{	
    		
	
    	repo.FrmMain.PodglądWydrukuInfo.WaitForExists(36000000);	
    		
    	
    	}   
the method turns on at the end of the TC and waits until the print preview window appears
When the error pops up, the popupwatcher closes it, but the method is waiting 10h, and all the rest of tc is blocked
I need to stop this code and go to next or teardown when error pops up

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3921
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Go to next step or teadrown

Post by odklizec » Mon Feb 19, 2018 1:11 pm

Yes, I understand. But as mentioned, this is not possible. Not with current popoup watcher implementation, which runs in a separated thread.

At first, why do you need to wait 10h? I think this alone is ridiculous timeout value. You should probably rethink your test case?

There is a way to kill the test from popup watcher, but it will not set the test a failed (described here).
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

yaro2o
Posts: 51
Joined: Mon Jan 29, 2018 11:19 am

Re: Go to next step or teadrown

Post by yaro2o » Mon Feb 19, 2018 1:31 pm

In the program we have 1000 prints, one generates 10s, one generates 5h and more, the only one that is previewed is a grid with preview or a window with the status of generation that does not appear in every printout, so only the grid with preview remains.
Attachments
2018-02-19_13-28-11.gif
2018-02-19_13-28-11.gif (4.13 MiB) Viewed 309 times

McTurtle
Posts: 191
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: Go to next step or teadrown

Post by McTurtle » Wed Feb 21, 2018 3:15 pm

Hello yaro2o,

The WaitForExist is a timeout that will continue as soon as the element "repo.FrmMain.PodglądWydrukuInfo" appears. The popup watcher that is running on another threat in parallel will click away the error messages.

I assume that "repo.FrmMain.PodglądWydrukuInfo" is the print preview? In this case, the code of the test will continue only after the element appears. If it does not appear and error messages have already been handled by the popup watcher, then this step will actually take 10 hours to fail :) This is bad... Because, you wait 10 hours for nothing.

If I understand you correctly, then there are only two options (print preview or error). If this is the case, you should not use the popup watcher at all.

You could build a code method for that. You can make it a loop that checks every few seconds if the error has been displayed or if the print preview has been displayed. And you should also limit the loop somehow.

An example could look like this:
public void CheckForPopupOrPrintPreview(int NrOfIterations, int SingleSearchTimeoutInMs)
		{
			RepoItemInfo printPreviewInfo = repo.YourApplication.PrintPreviewInfo;
			RepoItemInfo errorMessageInfo = repo.YourApplication.ErrorMessageInfo;
			
			int i=0;
			
			do
			{
				Report.Info(String.Format("Search iteration nr.: {0} for element {1} Waiting for {2} ms.",(i+1).ToString(),printPreviewInfo.Name,SingleSearchTimeoutInMs.ToString()));
				if (printPreviewInfo.Exists(Duration.FromMilliseconds(SingleSearchTimeoutInMs))==true)
				{
					printPreviewInfo.FindAdapter<Ranorex.Button>().Click();
					Report.Success("Print preview has been displayed.");
					break;
				}
				
				Report.Info(String.Format("Search iteration nr.: {0} for element {1} Waiting for {2} ms.",(i+1).ToString(),printPreviewInfo.Name,SingleSearchTimeoutInMs.ToString()));
				if (errorMessageInfo.Exists(Duration.FromMilliseconds(SingleSearchTimeoutInMs))==true)
				{
					errorMessageInfo.FindAdapter<Ranorex.Button>().Click();
					Report.Failure("Error popup has been displayed.");
					break;
				}
				i++;
			}
			while (i<NrOfIterations);
			
			if(i==NrOfIterations)
			{
			Report.Failure("No error popup or print preview has been displayed within the given timeframe.");
			}
		}
Is this helpful?

Regards,
McTurtle