Usage of PopupWatcher class

Ask general questions here.
stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Usage of PopupWatcher class

Post by stapes » Tue Aug 09, 2016 10:18 am

When a PopupWatcher is instantiated, does it last through the entire Test Suite, just a Test Case or just a code module?

Code: Select all

// Create PopupWatcher  
 PopupWatcher myPopupWatcher = new PopupWatcher();  
   
 // Add a Watch using a RanoreXPath and triggering the Method CloseUpdateCheckDialog  
 myPopupWatcher.Watch("/form[@controlname='UpdateCheckForm']/button[@controlname='m_btnClose']", CloseUpdateCheckDialog);  
  
 // Add a Watch using the info object of a button and triggering the Method CloseUpdateCheckDialog  
 // myPopupWatcher.Watch(repo.UpdateCheckDialog.btCloseInfo, CloseUpdateCheckDialog);  
   
 // Add a Watch using the info object of the dialog and the info object of the button to click  
 // myPopupWatcher.WatchAndClick(repo.UpdateCheckDialog.SelfInfo, repo.UpdateCheckDialog.btCloseInfo);  
   
 // Add a Watch using a repository folder object and the info object of the button to click  
 // myPopupWatcher.WatchAndClick(repo.UpdateCheckDialog, repo.UpdateCheckDialog.btCloseInfo);  
  
 // Start PopupWatcher  
 myPopupWatcher.Start();  

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Usage of PopupWatcher class

Post by krstcs » Tue Aug 09, 2016 1:35 pm

What do you mean by "instantiated"? Do you mean when the object is instantiated or do you actually mean when the watcher (thread) is started?

In .NET -
A class instance (object) lasts until you deallocate the variable associated with it.

A thread lasts until you stop it, it finishes it's work, or you deallocate the variable associated with the class instance that refers to it (although this sometimes doesn't actually stop the thread, depending on how it's coded, but you won't have a handle to it anymore).
Shortcuts usually aren't...

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Re: Usage of PopupWatcher class

Post by stapes » Tue Aug 09, 2016 2:43 pm

Instantiate = create an instance? You are right, I want to know what happens after it is started. Does it continue to watch until the end of the whole Test Suite, or until you turn it off?
Last edited by stapes on Tue Aug 09, 2016 3:32 pm, edited 2 times in total.

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Re: Usage of PopupWatcher class

Post by stapes » Tue Aug 09, 2016 2:51 pm

Let me put this another way. If I run this code at the beginning of the Test Suite will it pick up a Somethings Wrong dialog any time during the Test Suite?

Code: Select all

public void createPopupWatcher()
{
	Thread dialogWatcher = new Thread(ClosePopUpDialogs);
	dialogWatcher.IsBackground = true;
	dialogWatcher.SetApartmentState(ApartmentState.STA);
	dialogWatcher.Start();
}
public static void ClosePopUpDialogs()
{
	while (true)
	{
		if (repo.IOS365Agile.Com365agileEnterprise365AgileTEST.SomethingsWrongContainer.SelfInfo.Exists() )
		{
			Report.Warn("Something's Wrong Dialog detected.");
			Thread.Sleep(300);
Report.Screenshot(repo.IOS365Agile.Com365agileEnterprise365AgileTEST.SomethingsWrongContainer.Self);
repo.IOS365Agile.Com365agileEnterprise365AgileTEST.SomethingsWrongContainer.ContainerOK.Touch();
		}
		Thread.Sleep(1000);
	}
}