/// <summary>
        /// Handles the logon dialog by filling in the username and password.
        /// </summary>
        /// <param name="window">The window.</param>
        /// <returns></returns>
        public override bool HandleDialog(WatiN.Core.Native.Windows.Window window)
        {
            if (runonce)
            {
                return(false);
            }

            if (CanHandleDialog(window))
            {
                runonce = true;
                // Find Handle of the "Frame" and then the combo username entry box inside the frame
                var systemCredentialsHwnd = GetSystemCredentialsHwnd(window);

                SetActiveWindow(window.Hwnd);
                Thread.Sleep(1000);

                SetForegroundWindow(window.Hwnd);
                Thread.Sleep(1000);

                var windowEnumarator = new WindowsEnumerator();
                var all = windowEnumarator.GetChildWindows(systemCredentialsHwnd);
                // Find input fields
                var edits = windowEnumarator.GetChildWindows(systemCredentialsHwnd, "Edit");

                Thread.Sleep(2000);
                // Enter userName
                var hwnd = new Hwnd(edits[0].Hwnd);
                hwnd.SetFocus();
                clearText(hwnd);
                hwnd.SendString(userName);

                hwnd.SendMessage(0x0102, '\t', 0);
                hwnd = null;
                Thread.Sleep(2000);

                // Enter password
                hwnd = new Hwnd(edits[1].Hwnd);
                hwnd.SetFocus();
                clearText(hwnd);
                hwnd.SendString(password);


                // Click OK button
                var windowButton = new WindowsEnumerator().GetChildWindows(window.Hwnd, w => w.ClassName == "Button" && new WinButton(w.Hwnd).Title == "OK").FirstOrDefault();
                if (windowButton != null)
                {
                    new WinButton(windowButton.Hwnd).Click();
                }
                //new WinButton(1, window.Hwnd).Click();
                //new WinButton(0, window.Hwnd).Click();

                return(true);
            }

            return(false);
        }
Beispiel #2
0
        public static List <BrowserIds> ListCollectInternetExplorerInstances()
        {
            var enumerator             = new WindowsEnumerator();
            List <BrowserIds> _browser = new List <BrowserIds>();

            var topLevelWindows = enumerator.GetTopLevelWindows("IEFrame");

            foreach (var mainBrowserWindow in topLevelWindows)
            {
                var windows = enumerator.GetChildWindows(mainBrowserWindow.Hwnd, "TabWindowClass");

                // IE6 has no TabWindowClass so use the IEFrame as starting point
                if (windows.Count == 0)
                {
                    windows.Add(mainBrowserWindow);
                }

                foreach (var window in windows)
                {
                    _browser.Add(new BrowserIds
                    {
                        ProcessID = window.ProcessID,
                        HWND      = window.Hwnd.ToString(),
                        Title     = window.Title
                    });
                }
            }

            return(_browser);
        }
Beispiel #3
0
        public void PrintCart()
        {
            PrintLink.Click();
            Thread.Sleep(1000);

            WindowsEnumerator we          = new WindowsEnumerator();
            Window            printDialog = we.GetChildWindows(IntPtr.Zero, "#32770").FirstOrDefault(w => w.Title == "Print");

            if (printDialog != null)
            {
                WebBrowser.Current.DialogWatcher.HandleWindow(printDialog);
                WebBrowser.Current.DialogWatcher.Remove(handler);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Handles the logon dialog by filling in the username and password.
        /// </summary>
        /// <param name="window">The window.</param>
        /// <returns></returns>
        public override bool HandleDialog(Window window)
        {
            if (CanHandleDialog(window))
            {
                // Find Handle of the "Frame" and then the combo username entry box inside the frame
                var systemCredentialsHwnd = GetSystemCredentialsHwnd(window);

                NativeMethods.SetActiveWindow(window.Hwnd);
                Thread.Sleep(50);

                NativeMethods.SetForegroundWindow(window.Hwnd);
                Thread.Sleep(50);

                var windowEnumarator = new WindowsEnumerator();

                // Find input fields
                var edits = windowEnumarator.GetChildWindows(systemCredentialsHwnd, "Edit");

                // Enter userName
                var hwnd = new Hwnd(edits[0].Hwnd);
                hwnd.SetFocus();
                hwnd.SendString(userName);

                // Enter password
                hwnd = new Hwnd(edits[1].Hwnd);
                hwnd.SetFocus();
                hwnd.SendString(password);

                // Click OK button
                new WinButton(1, window.Hwnd).Click();

                return(true);
            }

            return(false);
        }