Wait until

Ask general questions here.
SanMan
Posts: 147
Joined: Tue Apr 13, 2010 9:59 am

Wait until

Post by SanMan » Thu Apr 19, 2018 6:17 am

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)?

SanMan
Posts: 147
Joined: Tue Apr 13, 2010 9:59 am

Re: Wait until

Post by SanMan » Thu Apr 19, 2018 7:20 am

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)

qwertzu
Posts: 178
Joined: Wed Jan 25, 2017 11:08 am

Re: Wait until

Post by qwertzu » Fri Apr 20, 2018 2:23 pm

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

Vaughan.Douglas
Posts: 250
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Wait until

Post by Vaughan.Douglas » Mon Apr 23, 2018 1:04 pm

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

SanMan
Posts: 147
Joined: Tue Apr 13, 2010 9:59 am

Re: Wait until

Post by SanMan » Fri Apr 27, 2018 1:49 pm

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
Attachments
spinner.png
spinner.png (18.36 KiB) Viewed 319 times

SanMan
Posts: 147
Joined: Tue Apr 13, 2010 9:59 am

Re: Wait until

Post by SanMan » Mon Apr 30, 2018 1:06 pm

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?

Fergal
Certified Professional
Certified Professional
Posts: 298
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: Wait until

Post by Fergal » Mon Apr 30, 2018 3:01 pm

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.

SanMan
Posts: 147
Joined: Tue Apr 13, 2010 9:59 am

Re: Wait until

Post by SanMan » Wed May 02, 2018 6:44 am

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

[Here validation]

Ranorex.Report.SetupDefault(); ?


I have not tried Invoke action > WaitForDocumentLoaded

ahoisl
Certified Professional
Certified Professional
Posts: 125
Joined: Fri Sep 07, 2007 8:16 am

Re: Wait until

Post by ahoisl » Wed May 02, 2018 8:29 am

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

SanMan
Posts: 147
Joined: Tue Apr 13, 2010 9:59 am

Re: Wait until

Post by SanMan » Wed May 02, 2018 9:50 am

Thank you Alex,

this solution works!