Exemplo n.º 1
0
        public bool Exists()
        {
            if (window == null)
            {
                return(false);
            }

            return(window.Exists());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Determines if a dialog still exists by checking the the existance of the
        /// window.Hwnd and checking if the window is visible.
        /// </summary>
        /// <param name="dialog">The dialog.</param>
        /// <returns><c>true</c> if exists and visible, otherwise <c>false</c></returns>
        public bool Exists(Window dialog)
        {
            return(dialog.Exists() && dialog.Visible);

//	    bool exists = dialog.Exists();
//      Logger.LogAction("Exists: exists == " + exists.ToString());
//
//	    bool visible = dialog.Visible;
//      Logger.LogAction("Exists: visible == " + visible.ToString());
//
//      return exists && visible;
        }
Exemplo n.º 3
0
		public override bool HandleDialog(Window window)
		{
			if (CanHandleDialog(window))
			{
				this.window = window;

				while (window.Exists())
				{
					Thread.Sleep(200);
				}
				return true;
			}
			return false;
		}
Exemplo n.º 4
0
        public override bool HandleDialog(Window window)
        {
            if (CanHandleDialog(window))
            {
                this.window = window;

                while (window.Exists())
                {
                    Thread.Sleep(200);
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 5
0
        private bool HandledDownloadProgressDialog(Window window)
        {
            if (IsDownloadProgressDialog(window))
            {
                DownloadProgressDialog = window;

                var openOrRun = new WinButton(4377, new Hwnd(window.Hwnd));

                if (openOrRun.Enabled)
                {
                    var close = new WinButton(2, new Hwnd(window.Hwnd));
                    close.Click();

                    var actionUntilTimeOut = new TryFuncUntilTimeOut(TimeSpan.FromSeconds(5));
                    actionUntilTimeOut.Try(() => window.Exists());

                    // TODO: What to do if the window doesn't close after timeout?
                }

                return(true);
            }
            return(false);
        }
 public bool Exists()
 {
     return(_window != null && _window.Exists());
 }
Exemplo n.º 7
0
 /// <summary>
 /// Determines if a dialog still exists by checking the the existance of the
 /// window.Hwnd and checking if the window is visible.
 /// </summary>
 /// <param name="dialog">The dialog.</param>
 /// <returns><c>true</c> if exists and visible, otherwise <c>false</c></returns>
 public bool Exists(Window dialog)
 {
     return(dialog.Exists() && dialog.Visible);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Handles the dialogs to download (and save) a file
        /// Mainly used internally by WatiN.
        /// </summary>
        /// <param name="window">The window.</param>
        /// <returns></returns>
        public override bool HandleDialog(Window window)
        {
            // This if handles the File download dialog
            if (!HasHandledFileDownloadDialog && IsFileDownloadDialog(window))
            {
                window.ToFront();
                window.SetActivate();

                DownloadProgressDialog = new Window(window.ParentHwnd);

                WinButton btn = GetButtonToPress(window);
                btn.Click();

                hasHandledFileDownloadDialog = !Exists(window);

                if (HasHandledFileDownloadDialog)
                {
                    Logger.LogAction("Download started at " + DateTime.Now.ToLongTimeString());
                    Logger.LogAction("Clicked " + _optionEnum.ToString());
                }

                return(true);
            }

            // This if handles the download progress dialog
            if (IsDownloadProgressDialog(window))
            {
                DownloadProgressDialog = window;

                WinButton openOrRun = new WinButton(4377, new Hwnd(window.Hwnd));

                if (openOrRun.Enabled)
                {
                    WinButton close = new WinButton(2, new Hwnd(window.Hwnd));

                    close.Click();

                    SimpleTimer timer = new SimpleTimer(5);
                    while (!timer.Elapsed && window.Exists())
                    {
                        Thread.Sleep(200);
                    }
                }

                return(true);
            }

            // This if handles the File save as dialog
            if (IsFileSaveDialog(window))
            {
                Logger.LogAction("Saving Download file as " + saveAsFilename);

                DownloadProgressDialog = new Window(window.ParentHwnd);

                HandleFileSaveDialog(window);

                return(true);
            }

            // Window is not a dialog this handler can handle.
            return(false);
        }
Exemplo n.º 9
0
		/// <summary>
		/// Handles the dialogs to download (and save) a file
		/// Mainly used internally by WatiN.
		/// </summary>
		/// <param name="window">The window.</param>
		/// <returns></returns>
		public override bool HandleDialog(Window window)
		{
			// This if handles the File download dialog
			if (!HasHandledFileDownloadDialog && IsFileDownloadDialog(window))
			{
				window.ToFront();
				window.SetActivate();

				DownloadProgressDialog = new Window(window.ParentHwnd);

				WinButton btn = GetButtonToPress(window);
				btn.Click();

				hasHandledFileDownloadDialog = !Exists(window);

				if (HasHandledFileDownloadDialog)
				{
					Logger.LogAction("Download started at " + DateTime.Now.ToLongTimeString());
					Logger.LogAction("Clicked " + _optionEnum.ToString());
				}

				return true;
			}

			// This if handles the download progress dialog
			if (IsDownloadProgressDialog(window))
			{
				DownloadProgressDialog = window;

                WinButton openOrRun= new WinButton(4377, new Hwnd(window.Hwnd));

                if (openOrRun.Enabled)
                {
                    WinButton close = new WinButton(2, new Hwnd(window.Hwnd));

                    close.Click();
                    
                    SimpleTimer timer = new SimpleTimer(5);
                    while (!timer.Elapsed && window.Exists())
                    {
                        Thread.Sleep(200);
                    }
                }

				return true;
			}

			// This if handles the File save as dialog
			if (IsFileSaveDialog(window))
			{
				Logger.LogAction("Saving Download file as " + saveAsFilename);

				DownloadProgressDialog = new Window(window.ParentHwnd);

				HandleFileSaveDialog(window);

				return true;
			}

			// Window is not a dialog this handler can handle.
			return false;
		}
Exemplo n.º 10
0
		/// <summary>
		/// Determines if a dialog still exists by checking the the existance of the 
		/// window.Hwnd and checking if the window is visible.
		/// </summary>
		/// <param name="dialog">The dialog.</param>
		/// <returns><c>true</c> if exists and visible, otherwise <c>false</c></returns>
		public bool Exists(Window dialog)
		{
			return dialog.Exists() && dialog.Visible;

//	    bool exists = dialog.Exists();
//      Logger.LogAction("Exists: exists == " + exists.ToString());
//
//	    bool visible = dialog.Visible;
//      Logger.LogAction("Exists: visible == " + visible.ToString());
//      
//      return exists && visible;
		}