PopUpWatcher in Program.cs?

Class library usage, coding and language questions.
TestXYZ
Posts: 16
Joined: Thu Aug 29, 2013 12:55 pm

PopUpWatcher in Program.cs?

Post by TestXYZ » Fri Oct 04, 2013 4:41 pm

Hello,

How can I use a generic PopUpWatcher which should close Form1 (ButtonClick on "BtnOK"), if the Form1 occurs in any recording. So I have added the PopUpWatcher() in Program.cs

Code: Select all


class Program
{
        [STAThread]
        public static int Main(string[] args)
        {
         ...
         PopupWatcher myPopupWatcher = new PopupWatcher();
         myPopupWatcher.WatchAndClick(MyRepository1.Instance.Form1, MyRepository1.Instance.Form1.BtnOK);			
         // Start PopupWatcher
         myPopupWatcher.Start();
         ...

But it does not work. It works very well if I put the code in every single Recording.UserCode.cs.
How can I use PopUpWatcher for every recordings in the solution, if during execution the Form1 appears?

Many Thanks! Best Regards

TestXYZ
Posts: 16
Joined: Thu Aug 29, 2013 12:55 pm

Re: PopUpWatcher in Program.cs?

Post by TestXYZ » Mon Oct 07, 2013 4:48 pm

Hello,

I am sorry that it was my mistake: I have put the PopUpWatcher on wrong position in Main().
The PopUpWatcher should be instantiated before this code line in Program.cs:

Code: Select all

TestSuiteRunner.Run(typeof(Program), Environment.CommandLine);
It works now fine. Many thanks!

Best Regards

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: PopUpWatcher in Program.cs?

Post by Support Team » Mon Oct 07, 2013 8:13 pm

Hello,

Thank you for the information.
I am glad that you could solve the issue.

Regards,
Bernhard
.
Image