public void ShouldCount1IEInstance()
        {
            Process process = null;
            try
            {
                // GIVEN
                process = StartIE("about:blank");
                Assert.That(process, Is.Not.Null, "pre-condition: Expected an IE process");

                var browsers = new ShellWindows2();

                // WHEN
                var count = browsers.Count;

                foreach (IWebBrowser2 browser in browsers)
                {
                    Console.WriteLine(browser.LocationURL);
                }
                // THEN
                Assert.That(count, Is.EqualTo(1), "unexpected count");
            }
            finally
            {
                if (process != null) process.Kill();
            }
        }
Пример #2
0
        public void ShouldCount1IEInstance()
        {
            Process process = null;

            try
            {
                // GIVEN
                process = StartIE("about:blank");
                Assert.That(process, Is.Not.Null, "pre-condition: Expected an IE process");

                var browsers = new ShellWindows2();

                // WHEN
                var count = browsers.Count;

                foreach (IWebBrowser2 browser in browsers)
                {
                    Console.WriteLine(browser.LocationURL);
                }
                // THEN
                Assert.That(count, Is.EqualTo(1), "unexpected count");
            }
            finally
            {
                if (process != null)
                {
                    process.Kill();
                }
            }
        }
        public void ShouldBeAbleToEnumerateFoundInstances()
        {
            Process process1 = null;
            Process process2 = null;

            try
            {
                // GIVEN
                process1 = StartIE("about:blank");
                Assert.That(process1, Is.Not.Null, "pre-condition 1: Expected an IE process");

                process2 = StartIE(BaseWatiNTest.FramesetURI.AbsolutePath);
                Assert.That(process2, Is.Not.Null, "pre-condition 2: Expected an IE process");

                var browsers = new ShellWindows2();

                // WHEN
                var count = browsers.Count;

                foreach (IWebBrowser2 browser in browsers)
                {
                    Console.WriteLine(browser.LocationURL);
                }

                // THEN
                Assert.That(count, Is.EqualTo(2), "unexpected count");
            }
            finally
            {
                if (process1 != null && !process1.HasExited) process1.Kill();
                if (process2 != null && !process2.HasExited) process2.Kill();
            }
        }
Пример #4
0
        public void ShouldCount1IEInstance()
        {
            Process process = null;

            try
            {
                // GIVEN
                process = StartIE("about:blank");
                Assert.That(process, Is.Not.Null, "pre-condition: Expected an IE process");

                var browsers = new ShellWindows2();

                // WHEN
                var count = browsers.Count;

                foreach (IWebBrowser2 browser in browsers)
                {
                    Logger.LogDebug(browser.LocationURL);
                }
                // THEN
                Assert.That(count, Is.EqualTo(1), "unexpected count");
            }
            finally
            {
                IE.AttachTo <IE>(Find.ByUrl("about:blank")).Close();
                if (process != null && !process.HasExited)
                {
                    process.Kill();
                }
            }
        }
        public void ShouldCount1IEInstance()
        {
            Process process = null;
            try
            {
                // GIVEN
                process = StartIE("about:blank");
                Assert.That(process, Is.Not.Null, "pre-condition: Expected an IE process");

                var browsers = new ShellWindows2();

                // WHEN
                var count = browsers.Count;

                foreach (IWebBrowser2 browser in browsers)
                {
                    Logger.LogDebug(browser.LocationURL);
                }
                // THEN
                Assert.That(count, Is.EqualTo(1), "unexpected count");
            }
            finally
            {
                IE.AttachTo<IE>(Find.ByUrl("about:blank")).Close();
                if (process != null && !process.HasExited) process.Kill();
            }
        }
        public IE FindIEPartiallyInitialized(Constraint findBy)
        {
            var allBrowsers = new ShellWindows2();

            var context = new ConstraintContext();
            foreach (IWebBrowser2 browser in allBrowsers)
            {
                var ie = CreateBrowserInstance(new IEBrowser(browser));
                if (ie.Matches(findBy, context))
                    return ie;
            }

            return null;
        }
Пример #7
0
Файл: IE.cs Проект: minskowl/MY
        private static IE FindIEPartiallyInitialized(Constraint findBy)
        {
            var allBrowsers = new ShellWindows2();

            var context = new ConstraintContext();

            foreach (IWebBrowser2 browser in allBrowsers)
            {
                var ie = new IE(browser, false);
                if (ie.Matches(findBy, context))
                {
                    return(ie);
                }
            }

            return(null);
        }
Пример #8
0
        public void ShouldBeAbleToEnumerateFoundInstances()
        {
            Process process1 = null;
            Process process2 = null;

            try
            {
                // GIVEN
                process1 = StartIE("about:blank");
                Assert.That(process1, Is.Not.Null, "pre-condition 1: Expected an IE process");

                process2 = StartIE(BaseWatiNTest.FramesetURI.AbsolutePath);
                Assert.That(process2, Is.Not.Null, "pre-condition 2: Expected an IE process");

                var browsers = new ShellWindows2();

                // WHEN
                var count = browsers.Count;

                foreach (IWebBrowser2 browser in browsers)
                {
                    Logger.LogDebug(browser.LocationURL);
                }

                // THEN
                Assert.That(count, Is.EqualTo(2), "unexpected count");
            }
            finally
            {
                IE.AttachTo <IE>(Find.ByUrl("about:blank")).Close();
                IE.AttachTo <IE>(Find.ByUrl(BaseWatiNTest.FramesetURI.AbsolutePath)).Close();
                if (process1 != null && !process1.HasExited)
                {
                    process1.Kill();
                }
                if (process2 != null && !process2.HasExited)
                {
                    process2.Kill();
                }
            }
        }
Пример #9
0
        public IECollection(bool waitForComplete)
        {
            findBy = Find.Any;
            this.waitForComplete = waitForComplete;

            internetExplorers = new List <IE>();
            var allBrowsers = new ShellWindows2();

            foreach (IWebBrowser2 internetExplorer in allBrowsers)
            {
                try
                {
                    if (internetExplorer.Document is IHTMLDocument2)
                    {
                        var ie = new IE(internetExplorer);
                        internetExplorers.Add(ie);
                    }
                }
                catch { }
            }
        }