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)?
Wait until
Re: Wait until
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)
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
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.
regards, qwertzu
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);
}
}
-
- Posts: 254
- Joined: Tue Mar 24, 2015 5:05 pm
- Location: Des Moines, Iowa, USA
Re: Wait until
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.
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
Re: Wait until
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
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 (18.36 KiB) Viewed 1753 times
Re: Wait until
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?
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?
-
- Certified Professional
- Posts: 344
- Joined: Tue Feb 18, 2014 2:14 pm
- Location: Co Louth, Ireland
- Contact:
Re: Wait until
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
Ranorex.Report.Setup(ReportLevel.None, null, true);
[Here validation]
Ranorex.Report.SetupDefault(); ?
I have not tried Invoke action > WaitForDocumentLoaded
[Here validation]
Ranorex.Report.SetupDefault(); ?
I have not tried Invoke action > WaitForDocumentLoaded
Re: Wait until
Please, don't do that, it will cause your reporting to go haywire.SanMan wrote:Ranorex.Report.Setup(ReportLevel.None, null, true);
[Here validation]
Ranorex.Report.SetupDefault(); ?
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
Thank you Alex,
this solution works!
this solution works!