public void SetUpWindowsTestFixture()
        {
            enumerator = new WindowsEnumerator();

            p = new Process();
            p.StartInfo.FileName = "iexplore";
            p.Start();

            DateTime timeout = DateTime.Now.AddSeconds(10);
            while (DateTime.Now < timeout && Process.GetProcessesByName("iexplore").Length == 0)
                Thread.Sleep(1000);

            Thread.Sleep(2000);
        }
        private IntPtr GetTestWindowHandle(string windowTitle)
        {
            WindowsEnumerator enumerator = new WindowsEnumerator();

            foreach (ApiWindow window in enumerator.GetTopLevelWindows())
            {
                if (window.MainWindowTitle.Contains(windowTitle))
                {
                    return new IntPtr(window.hWnd);
                }
            }

            return IntPtr.Zero;
        }
        internal override IntPtr GetJSDialogHandle(int timeoutSeconds)
        {
            // Ignore timeout length

            // Find all top level chrome windows
            WindowsEnumerator enumerator = new WindowsEnumerator();
            List<ApiWindow> windows = enumerator.GetTopLevelWindows("Chrome_WidgetWin_0");

            foreach (string windowTitle in jsDialogWindowSubstrings)
            {
                //NativeMethods.GetWindowWithSubstring(windowTitle, 0, 0, ref dialogHwnd);

                // Loop through all of the chrome windows
                foreach (ApiWindow window in windows)
                {
                    // if the title matches
                    if (window.MainWindowTitle.Contains(windowTitle))
                    {
                        IntPtr dialogHwnd = new IntPtr(window.hWnd);

                        // check if the window has a Button within it
                        IntPtr buttonHandle = NativeMethods.GetChildWindowHwnd(dialogHwnd, "Button");

                        // if there is a Button then it is a JavaScript Dialog and not a regular window
                        if (buttonHandle != IntPtr.Zero)
                            return dialogHwnd;

                        // its a JS Dialog but the buttons dont have handles, the sleep will give time to the slow JS Dialogs to load
                        Sleep(1200);
                        return dialogHwnd;
                    }
                }
            }

            return IntPtr.Zero;
        }