Пример #1
0
        public void Should_have_dialogwatcher_set_when_instantiated_by_calling_IntenetExplorers()
        {
            // GIVEN
            using (var ie1 = new IE())
                using (var ie2 = new IE())
                {
                    // WHEN
                    var internetExplorers = IE.InternetExplorers();

                    // THEN
                    Assert.That(internetExplorers.All(browser => browser.DialogWatcher != null));
                }
        }
Пример #2
0
        private void DoRefresh()
        {
            var       browsers = new List <Browser>();
            Exception error    = null;

            try
            {
                browsers.AddRange(IE.InternetExplorers());
            }
            catch (Exception ex)
            {
                error = ex;
            }
            ContinueRefresh(error, browsers);
        }
Пример #3
0
        public MsCrmWrapper(int id, string name, string by = "title", bool mscrmRecorder = false)
        {
            Ie = null;
            try
            {
                this.Id = id;
                string       search = name.ToLower();
                IECollection list   = IE.InternetExplorers();
                foreach (var item in list)
                {
                    if (by.ToLower() == "title")
                    {
                        if (item.Title.ToLower().Contains(search))
                        {
                            Ie = item;
                            break;
                        }
                    }
                    else
                    {
                        if (item.Url.ToLower().Contains(search))
                        {
                            Ie = item;
                            break;
                        }
                    }
                }

                if (Ie != null)
                {
                    Address = Ie.Url;
                }
            }
            catch
            {
                throw new TimeoutException("Timeout occured while attaching to Internet Explorer / CRM");
            }
            if (mscrmRecorder && Ie?.InternetExplorer != null)
            {
                MsCrmRecordingSwitch = true;
                SHDocVw.InternetExplorer webBrowser = (SHDocVw.InternetExplorer)Ie.InternetExplorer;
                webBrowser.DocumentComplete += ReinjectJavascriptListeners;
                object unimportant = null;
                ReinjectJavascriptListeners(null, ref unimportant);
            }
        }
Пример #4
0
        public void CloseBrowser()
        {
            if (ie == null)
            {
                return;
            }
            ie.Close();
            ie = null;
            if (IE.InternetExplorers().Count == 0)
            {
                return;
            }

            foreach (var explorer in IE.InternetExplorersNoWait())
            {
                Console.WriteLine(explorer.Title + " (" + explorer.Url + ")");
                explorer.Close();
            }
            throw new Exception("Expected no open IE instances.");
        }
Пример #5
0
 public static void CloseAllIEWindows()
 {
     try
     {
         for (int x = IE.InternetExplorers().Count() - 1; x > 0; x--)
         {
             IE test = IE.InternetExplorers()[x];
             try
             {
                 test.Close();
             }
             catch (Exception e)
             {
                 Console.WriteLine("Error closing IE windows: " + e.Message);
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error closing IE windows: " + ex.Message);
     }
 }
Пример #6
0
        public void IECollectionExcludesWindowsExplorerWindows()
        {
            // Bring up an Explorer window and wait for it to become visible.
            var info = new ProcessStartInfo("explorer.exe")
            {
                UseShellExecute = false, CreateNoWindow = true
            };

            var p = Process.Start(info);

            try
            {
                Thread.Sleep(2000);

                // Create an IE window so we know there's at least one of them.
                new IE();

                // Iterate over internet explorer windows.
                // Previously this would pick up a reference to the Windows Explorer
                // window which would timeout while waiting for the main document to
                // become available.
                Assert.GreaterOrEqual(IE.InternetExplorers().Count, 1);

                foreach (var ie in IE.InternetExplorers())
                {
                    ie.Close();
                }
            }
            finally
            {
                if (p != null)
                {
                    if (!p.HasExited)
                    {
                        p.Kill();
                    }
                }
            }
        }
Пример #7
0
 /// <summary>
 /// Creates an instance of WindowCollection and collects all of the visible windows.
 /// </summary>
 public WindowCollection()
 {
     _windows = IE.InternetExplorers();
 }