Ejemplo n.º 1
0
        private WinButton GetButtonToPress(Window window)
        {
            WinButton btn = null;

            switch (_optionEnum)
            {
            case FileDownloadOptionEnum.Run:
                btn = new WinButton(4426, window.Hwnd);
                break;

            case FileDownloadOptionEnum.Open:
                btn = new WinButton(4426, window.Hwnd);
                break;

            case FileDownloadOptionEnum.Save:
                btn = new WinButton(4427, window.Hwnd);
                if (!btn.Exists())
                {
                    btn = new WinButton(4424, window.Hwnd);
                }
                break;

            case FileDownloadOptionEnum.Cancel:
                btn = new WinButton(2, window.Hwnd);
                break;
            }

            return(btn);
        }
 public void CloseDialog()
 {
     if (msg == "The webpage you are viewing is trying to close the tab.\n\nDo you want to close this tab?" ||
         msg == "The webpage you are viewing is trying to close the window.\n\nDo you want to close this window?")
     // It does not seem as though this dialog is properly handled, resulting in an uncaught exception
     {
         WinButton yesButton = new WinButton(6, _window.Hwnd); // Not sure if ID will always be 6, but with the current example it is
         if (yesButton.Exists())
         {
             yesButton.Click();
         }
     }
     if (_window != null)
     {
         _window.ForceClose();
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the dialog if the <paramref name="window" /> is a
        /// security alert dialog.
        /// </summary>
        /// <param name="window">The window.</param>
        /// <returns></returns>
        public override bool HandleDialog(Window window)
        {
            if (CanHandleDialog(window))
            {
                NativeMethods.SetForegroundWindow(window.Hwnd);
                NativeMethods.SetActiveWindow(window.Hwnd);

                var buttonOk = new WinButton(1, window.Hwnd);
                if (buttonOk.Exists())
                {
                    buttonOk.Click();
                }
                else
                {
                    var buttonYes = new WinButton(6, window.Hwnd);
                    buttonYes.Click();
                }

                return(true);
            }

            return(false);
        }
Ejemplo n.º 4
0
		protected bool ButtonWithId1Exists(IntPtr windowHwnd)
		{
			WinButton button = new WinButton(1, windowHwnd);
			return button.Exists();
		}
Ejemplo n.º 5
0
        protected bool ButtonWithId1Exists(IntPtr windowHwnd)
        {
            WinButton button = new WinButton(1, windowHwnd);

            return(button.Exists());
        }
Ejemplo n.º 6
0
		private WinButton GetButtonToPress(Window window)
		{
			WinButton btn = null;

			switch (_optionEnum)
			{
				case FileDownloadOptionEnum.Run:
					btn = new WinButton(4426, window.Hwnd);
					break;

				case FileDownloadOptionEnum.Open:
					btn = new WinButton(4426, window.Hwnd);
					break;

				case FileDownloadOptionEnum.Save:
					btn = new WinButton(4427, window.Hwnd);
					if (!btn.Exists())
					{
						btn = new WinButton(4424, window.Hwnd);
					}
					break;

				case FileDownloadOptionEnum.Cancel:
					btn = new WinButton(2, window.Hwnd);
					break;
			}

			return btn;
		}
        public static bool ButtonWithId1Exists(IntPtr windowHwnd)
        {
            var button = new WinButton(1, windowHwnd);

            return(button.Exists());
        }