Page 1 of 1

Usage of PopupWatcher class

Posted: Tue Aug 09, 2016 10:18 am
by stapes
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();  

Re: Usage of PopupWatcher class

Posted: Tue Aug 09, 2016 1:35 pm
by krstcs
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).

Re: Usage of PopupWatcher class

Posted: Tue Aug 09, 2016 2:43 pm
by stapes
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?

Re: Usage of PopupWatcher class

Posted: Tue Aug 09, 2016 2:51 pm
by stapes
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);
	}
}