Page 1 of 1

Wait until

Posted: Thu Apr 19, 2018 6:17 am
by SanMan
I have a spinner that appears and disappears quite randomly.

I know quite well when spinner should appear but how long it is shown is quite random time.

What I want is a check that looks if spinner is found and if it is found, it will wait until it does not exist anymore.

Now I have used "WaitForNotExists" but there should set some fixed time how long it is waited?

What would be the best solution for my case (check if found and wait until not exist anymore)?

Re: Wait until

Posted: Thu Apr 19, 2018 7:20 am
by SanMan
I am using now:

bool spinner=Validate.Exists(repo.SpinnerFastInfo, Validate.DefaultMessage, false);

Only problem now is that in report I will get:

Failure Validation Element for item 'SpinnerFast' does not exist (Failed to find item...)

Can I somehow get rid of this Failure Validation ? (as it is wanted that this item does not exist anymore)

Re: Wait until

Posted: Fri Apr 20, 2018 2:23 pm
by qwertzu
hi,

since you mentioned that you know when the spinner appears, you could simply add a WaitForExists method and directly afterwards a WaitForNotExists mehtod.
In this case, Ranorex waits until the spinner exists and continues the test until it disappeared

However, this will only work if you know exactly when the spinner appears. If it may appear in a random step of your test, you will have to implement a new thread in which you wait for the spinner to exists. This would work like a popupwatcher thread.
The problem here will be that your test will not be paused because it runs in a separate thread.

I have an example here for an additional thread which waits for the google searchbar to exist and if it exists, it waits for it to disappear.

Code: Select all

public void popupThread()
		{
			

			// Creates and starts a new thread
			// which handles unexpected dialogs
			Thread dialogWatcher = new Thread(ClosePopUpDialogs);
			dialogWatcher.IsBackground = true;
			dialogWatcher.SetApartmentState(ApartmentState.STA);
			dialogWatcher.Start();
			
		}
		
		
		public static void ClosePopUpDialogs()
		{
			while (true)
			{
				if (repo.Google.LstIbInfo.Exists() )
				{
					
					//report that the google searchbar exists and wait for it to disappear
					Thread.Sleep(300);
					Report.Info("Google searchbar does exist");
					repo.Google.LstIbInfo.WaitForNotExists(900000);
					Report.Info("Google Searchbar doesnt exist anymore");
					
				}
				
				Thread.Sleep(1000);

				
			}
		}
regards, qwertzu

Re: Wait until

Posted: Mon Apr 23, 2018 1:04 pm
by Vaughan.Douglas
If this is a web application, I would start by adding @state='complete' to the DOM level repo item.

Regardless of the type of application we're dealing with (web or otherwise) when dealing with some sort of synchronization issue, I handle this through more lenient wait times and a paranoid level of "WaitforExist" steps. The WaitForExist can also be configured to Wait for "AttributeEqual" among other options.
I've used this approach when an element is onscreen but undergoes a change during the step immediately proceeding its use. In that case I waited for the "valid" attribute to be true then I wanted for the "enabled" attribute to be true. Think of it much in the same way you'd use the validate class, except you don't want an explicit pass/fail recorded in the report. Also keep in mind these wait for actions will return immediately when the condition is met, so you'll only wait for that full timeout when something's gone south.

Re: Wait until

Posted: Fri Apr 27, 2018 1:49 pm
by SanMan
Hi,

yes, it is a web app.

" @state='complete' to the DOM level repo item."

So should I just add [@state='complete'] to spinner repo item?

Best Regards,

SanMan

Re: Wait until

Posted: Mon Apr 30, 2018 1:06 pm
by SanMan
Hi again,

Ranorex.Report.Setup(ReportLevel.None, null, true);

With this I can get rid of the validation error.

After run this spinner validation, I want to enable reporting again.

How to enable back the default reporting level?

Re: Wait until

Posted: Mon Apr 30, 2018 3:01 pm
by Fergal
SanMan have you tried using an Invoke action > WaitForDocumentLoaded for the web page you are testing? If it works you may not have to deal with the spinner, just wait for the web page to load, then continue with the test.

Re: Wait until

Posted: Wed May 02, 2018 6:44 am
by SanMan
Ranorex.Report.Setup(ReportLevel.None, null, true);

[Here validation]

Ranorex.Report.SetupDefault(); ?


I have not tried Invoke action > WaitForDocumentLoaded

Re: Wait until

Posted: Wed May 02, 2018 8:29 am
by ahoisl
SanMan wrote:Ranorex.Report.Setup(ReportLevel.None, null, true);

[Here validation]

Ranorex.Report.SetupDefault(); ?
Please, don't do that, it will cause your reporting to go haywire.

If you don't want to do a validation, why do you use the Validation class/action then? Just use the RepoItemInfo.WaitForExists method or a WaitForExists recorder action (which uses the WaitForExists method internally).

Regards,
Alex
Ranorex Team

Re: Wait until

Posted: Wed May 02, 2018 9:50 am
by SanMan
Thank you Alex,

this solution works!