Esempio n. 1
0
        protected override void WaitForCompleteOrTimeout()
        {
            if (ieBrowser != null)
            {
                if (!WaitWhileIEBusy(ieBrowser.WebBrowser))
                {
                    return;
                }
                if (!WaitWhileIEReadyStateNotComplete(ieBrowser.WebBrowser))
                {
                    return;
                }

                ieDocument = (IEDocument)ieBrowser.NativeDocument;
            }

            if (ieDocument == null)
            {
                return;
            }

            WaitWhileMainDocumentNotAvailable(ieDocument.HtmlDocument);
            WaitWhileDocumentStateNotComplete(ieDocument.HtmlDocument);
            WaitForFramesToComplete(ieDocument.HtmlDocument);
        }
Esempio n. 2
0
        public void UrlShouldReturnUrlOfCurrentDocument()
        {
            // GIVEN
            var ieDocument = new IEDocument((IHTMLDocument2)((SHDocVw.IWebBrowser2)Ie.InternetExplorer).Document);

            // WHEN
            var url = ieDocument.Url;

            // THEN
            Assert.That(new Uri(url), Is.EqualTo(MainURI));
        }
        public void ActiveElementShouldReturnActiveElement()
        {
            // GIVEN
            Ie.CheckBox("Checkbox1").Focus();
            var ieDocument = new IEDocument((IHTMLDocument2)((SHDocVw.IWebBrowser2)Ie.InternetExplorer).Document);

            // WHEN
            var activeElement = ieDocument.ActiveElement;

            // THEN
            Assert.That(activeElement.GetAttributeValue("id"), Is.EqualTo("Checkbox1"));
        }
Esempio n. 4
0
        public void NativeDocumentShouldBeSetByConstructor()
        {
            // GIVEN
            var htmlDocument2Mock = new Mock<IHTMLDocument2>();
            var htmlDocument = htmlDocument2Mock.Object;
            var ieDocument = new IEDocument(htmlDocument);

            // WHEN
            var nativeDocument = ieDocument.HtmlDocument;

            // THEN
            Assert.That(ReferenceEquals(nativeDocument, htmlDocument));
        }
Esempio n. 5
0
        public void NavigateTo(Uri url)
        {
            var htmlDoc = new HTMLDocumentClass();
            var ips = (IPersistStreamInit)htmlDoc;
            ips.InitNew();

            var htmlDoc2 = htmlDoc.createDocumentFromUrl(url.AbsoluteUri, "null");

            while (htmlDoc2.readyState != "complete")
            {
                //This is also a important part, without this DoEvents() appz hangs on to the “loading”
                Application.DoEvents();
            }
            _ieDocument = new IEDocument(htmlDoc2);
        }
Esempio n. 6
0
        protected override void WaitForCompleteOrTimeout()
        {
            if (ieBrowser != null)
            {
                if (!WaitWhileIEBusy(ieBrowser.WebBrowser))
                    return;
                if (!WaitWhileIEReadyStateNotComplete(ieBrowser.WebBrowser))
                    return;

                ieDocument = (IEDocument)ieBrowser.NativeDocument;
            }

            if (ieDocument == null) return;
            
            WaitWhileMainDocumentNotAvailable(ieDocument.HtmlDocument);
            WaitWhileDocumentStateNotCompleteOrInteractive(ieDocument.HtmlDocument);
            WaitForFramesToComplete(ieDocument.HtmlDocument);
        }
        public void BodyShouldReturnAnIENativeElement()
        {
            // GIVEN
            var htmlElementMock = new Mock<IHTMLElement>();
            var htmlElement = htmlElementMock.Object;

            var htmlDocument2Mock = new Mock<IHTMLDocument2>();
            htmlDocument2Mock.Expect(document => document.body).Returns(htmlElement);
            var htmlDocument = htmlDocument2Mock.Object;

            var ieDocument = new IEDocument(htmlDocument);

            // WHEN
            var nativeElement = ieDocument.Body;

            // THEN
            IEElement ieElement = (IEElement)nativeElement;
            Assert.That(ReferenceEquals(ieElement.AsHtmlElement, htmlElement), "Unexpected instance");
        }
        public void RunScriptShouldCallNativeDocumentProperty()
        {
            // GIVEN
            var htmlDocumentMock = new Mock<IHTMLDocument2>();
            var parentWindowMock = new Mock<IHTMLWindow2>();
            htmlDocumentMock.Expect(doc => doc.parentWindow).Returns(parentWindowMock.Object);
            var htmlDocument = htmlDocumentMock.Object;
            var ieDocument = new IEDocument(htmlDocument);

            // WHEN
            ieDocument.RunScript("Somescript", "javascript");

            // THEN
            parentWindowMock.Verify(window => window.execScript("Somescript", "javascript"));
        }
        public void TitleShouldReturnTitleofThePage()
        {
            // GIVEN
            var ieDocument = new IEDocument((IHTMLDocument2)((SHDocVw.IWebBrowser2)Ie.InternetExplorer).Document);

            // WHEN
            var title = ieDocument.Title;

            // THEN
            Assert.That(title, Is.EqualTo("Main"));
        }
Esempio n. 10
0
 public IEWaitForComplete(IEDocument ieDocument, int waitForCompleteTimeout)
     : base (waitForCompleteTimeout)
 {
     this.ieDocument = ieDocument;
 }
Esempio n. 11
0
 public IEWaitForComplete(IEDocument ieDocument)
     : this(ieDocument, Settings.WaitForCompleteTimeOut)
 {
 }
Esempio n. 12
0
 public IEWaitForComplete(IEDocument ieDocument, int waitForCompleteTimeout)
     : base(waitForCompleteTimeout)
 {
     this.ieDocument = ieDocument;
 }
Esempio n. 13
0
 public IEWaitForComplete(IEDocument ieDocument)
     : this(ieDocument, Settings.WaitForCompleteTimeOut)
 {
 }
 public JScriptElementArrayEnumerator(IEDocument ieDocument, string fieldName)
 {
     _ieDocument = ieDocument;
     _fieldName  = fieldName;
 }