How to implement continous checking in background

Class library usage, coding and language questions.
andrea.gualdoni
Posts: 5
Joined: Wed Nov 27, 2013 5:28 pm

How to implement continous checking in background

Post by andrea.gualdoni » Tue Dec 17, 2013 11:13 am

Dear All,

here's my problem.

We are using ranorex validating a web site. We have a DIV "Please Wait" that always "exists" and appear/disappears relating to the value of his "Visible" property.

This "Please Wait" pop up verytime system is loading data, store data on db. Its duration depends on lots of parameters so we cannot use statical delay.

We found a way to make this efficient.

Code: Select all

   
public void WaitLoading()
        {
			Validate.Exists(repo.WebDocumentIE.PleaseWaitDIV,"",false);       
        	bool a = repo.WebDocumentIE.PleaseWaitDIV.Visible;
        	int i=0;

			while (a)
	        {
				a = repo.WebDocumentIE.PleaseWaitDIV.Visible;
	        }					
        }
Now "next step". I don't want to call this method after every action i will make in every test case from now on. So I would like a "background" check would be always present and everytime the PleaseWaitDiv exist it makes this check. How can I implement this? Calling something in the Main class?

thx a lot in advance for help

Andrea

User avatar
BernhardS
Ranorex Guru
Ranorex Guru
Posts: 32
Joined: Tue Dec 17, 2013 6:35 pm

Re: How to implement continous checking in background

Post by BernhardS » Fri Dec 20, 2013 1:17 pm

Hello Andrea,

Unfortunately there is no easy way in order to solve the issue in Ranorex directly, but you can, for example try to use the PopupWatcher class of Ranorex in order to recognize the popup. The problem is that the PopupWatcher will create a new thread and if you call your wait method from the PopupWatcher the main thread will not wait until your method is ready. In that case you have to pause the main thread. Please take a look at the post "Second Ranorex Thread checking for AUT Exceptions" in order to get some hints how to work with threads.

Regards,
Bernhard

andrea.gualdoni
Posts: 5
Joined: Wed Nov 27, 2013 5:28 pm

Re: How to implement continous checking in background

Post by andrea.gualdoni » Thu Jan 09, 2014 4:27 pm

After Vacation i came back at work and found a workaround, not using thread, that works.

Now next step. I would like that this "check" would work after EVERY step of EVERY test case by default (so not copying and paste this code after each step of each test case).

Is there a way to put a default behaviour like this? So to specify that "something" has to be done after every test iteration?

andrea.gualdoni
Posts: 5
Joined: Wed Nov 27, 2013 5:28 pm

Re: How to implement continous checking in background

Post by andrea.gualdoni » Tue Jan 14, 2014 12:24 pm

Up of the thread cause probably i was not so clear on my request :-)

The following method is a simple way to handle my situation (ie waiting about a div to become not visible before "go on")

Code: Select all

        public void WaitLoading()
        {
		Validate.Exists(repo.WebDocumentIE.PleaseWaitDIV,"",false);       
        	bool a = repo.WebDocumentIE.PleaseWaitDIV.Visible;
        	int i=0;

		while (a)
	        {
				a = repo.WebDocumentIE.PleaseWaitDIV.Visible;
	        }					
        }
Now i have to call this method manually after EVERY step of my tests... my question is simple:

"Is there a way to handle this situation automatically?"

"Is there a place where i can define a method is called after EVERY test step of EVERY test case?"

I fear not, but maybe there is a workaround or you can suggest me something.

Thx a lot in advance

andrea

User avatar
BernhardS
Ranorex Guru
Ranorex Guru
Posts: 32
Joined: Tue Dec 17, 2013 6:35 pm

Re: How to implement continous checking in background

Post by BernhardS » Wed Jan 15, 2014 4:18 pm

Hello Andrea,
"Is there a way to handle this situation automatically?"
We are working on a "Wait for exists" functionality at the moment which could help you solving your issue.
Unfortunately I cannot give you a time frame when it will be released.
"Is there a place where i can define a method is called after EVERY test step of EVERY test case?"
Unfortunately this is not possible automatically. I would recommend to create a recording only for this method and copy this recording in the Teardown section of each test case.

Regards,
Bernhard