Teardown

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

Re: Teardown

Post by yaro2o » Thu Feb 22, 2018 10:34 am

k another question, what will be the best code to close these windows if they exist? while loop? how to add instructions so that you do not get a bug if ranorex do not find them? now it looks like if the the windows exist raport = success if there are no windows raport = Error

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

Re: Teardown

Post by odklizec » Thu Feb 22, 2018 10:55 am

I’m sorry, but I’m somwhow lost here. If the test you designed opens a window, the same test should close it at the end of test. Why should any window remain open? I simply don’t understand the need of using some kind of loop or even popupwatcher? Popupwatcher as such, is designed to catch and close “unexpected” windows and dialogs, which is not your case. Your windows appear to be expected? Windows you want to close, were started by some actions in your test. So you should close them from the very same test, right after they are no longer required and not via popupwatcher or loop placed somewhere at the end of test suite.
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: Teardown

Post by yaro2o » Thu Feb 22, 2018 11:16 am

We do not understand each other, the ideal world should look like this:

1. I open the print dialog
2. I complete the fields on 1 dialogue
3. I go to the 2 printout dialog
4. I complete the dialog boxes
5. I close dialog 2 with OK
6. I click the Print button
7. A print preview after x time is generated
8. I close the print preview and I am at the beginning, that is, I open the dialogue again, etc.

In fact:

1. I open the print dialog
2. I complete the fields on 1 dialogue
3. I go to the 2 printout dialog
4. I complete the dialog boxes
5. I close dialog 2 with OK
6. Receives Error
7. Popupwatcher closes the error
8. Ranorex looks for the Print button but is in dialogue 2 so he can not find it
9. Goes to TC2 where he should open the dialog but he can not because he has 2 windows from the previous TC displayed

Now the question is what to add to Teardown?

Closing windows with the continue on fail? Option

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

Re: Teardown

Post by yaro2o » Thu Feb 22, 2018 12:03 pm

The best option at the end of each TC will be close app and run again at setup on next TC ?

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

Re: Teardown

Post by odklizec » Thu Feb 22, 2018 4:04 pm

5. I close dialog 2 with OK
6. Receives Error
7. Popupwatcher closes the error
8. Ranorex looks for the Print button but is in dialogue 2 so he can not find it
And this is exactly where I think you should fail the TC and close the app, instead if using popupwatcher to kill the Error.

Showing error instead of expected dialog is in my opinion failure? So why bothering with some kind of workaround? ;) Someone should fix this behavior or have a very good explanation of error.

If I understand it right, the error occasionally appears after step 5 (only after step 5)? So in my opinion, instead of using popupwatcher, you should add a new code/recording module, right after the step 5, in which you can add some "optional" steps, which would wait for the appearance of error (with timeout). If the error does not appear within defined timeout period, "optional" steps will not cause the TC failure and the test should continue as expected. However, if the error appears, you should set the test as failed (and eventually and terminate the AUT).
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: Teardown

Post by yaro2o » Thu Feb 22, 2018 5:20 pm

No, this is just an example Error can occur anywhere, it happens differently. One printout heave about 50 TC, and everyone TC has an identical beginning and end. Should I close the program after each TC and run it again? Should I close the program after each TC and run it again? it would be the simplest solution and would eliminate all doubts. The program is written in delphi and not everything can be done well.

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

Re: Teardown

Post by yaro2o » Fri Feb 23, 2018 10:46 am

Hi Tell me why ranorex makes loops while since the window is not visible ? and how set the search time for everything in this code to a smaller one ?

Code: Select all

Duration searchTimeout1 = new Duration(10); // time in ms  
			 

          try
       
          {

          	repo.FrmMain.Zamknij1.Click();
          		
          }

          catch
          {
          	
          	while (repo.Clean.uniwersal.Self.Visible)
          		{
          		repo.Clean.uniwersal.Self.Close();
          		}	
          }
          
          finally
          {
          	repo.FrmMain.Aplikacja.Focus();
          	Delay.Seconds(1);
          	repo.FrmMain.Zamknij.Touch();
          }


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

Re: Teardown

Post by McTurtle » Tue Feb 27, 2018 2:55 pm

Hello yaro2o,

You need to change the timeout for each specific adapter. The adapters have been created with the default value already. You should use the following:
repo.FrmMain.Zamknij1Info.SearchTimeout=new Duration(10);
However, this is too short and will fail your test :) The question is, why you would like to change that value? It will only fail your test faster, if the element is there, then the search will not be faster because of a shorter timeout.

Furthermore, if the element repo.Clean.uniwersal is not there, then your code should not loop through the while loop. Have you already attempted to debug?

Regards,
McTurtle

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

Re: Teardown

Post by yaro2o » Wed Feb 28, 2018 2:43 pm

I've already solved my problem, I used the if and else loop, the problem was the lack of given waiting time, strange but true, or always went into loops or not