Exemplo n.º 1
0
        private static IExpando GetWindow(INativeDocument document)
        {
            IEDocument     ieDoc   = document as IEDocument;
            IHTMLDocument2 htmlDoc = ieDoc.HtmlDocument;

            return(htmlDoc.parentWindow as IExpando);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This constructor will mainly be used by the constructor of FrameCollection
        /// to create an instance of a Frame.
        /// </summary>
        /// <param name="domContainer">The domContainer</param>
        /// <param name="frameDocument">The document within the frame</param>
        public Frame(DomContainer domContainer, INativeDocument frameDocument)
            : base(domContainer)
        {
            if (frameDocument == null)
                throw new ArgumentNullException("frameDocument");

            _frameDocument = frameDocument;
            _frameElement = new Element(domContainer, frameDocument.ContainingFrameElement);
        }
Exemplo n.º 3
0
        public static T Eval <T>(this INativeDocument document, string code, string type)
        {
            IExpando     window   = GetWindow(document);
            PropertyInfo property = CreateOrGetProperty(window, "__lastEvalResult");

            document.RunScript("window.__lastEvalResult = " + code + ";", type);
            var result = (T)property.GetValue(window, null);

            return(result);
        }
        /// <summary>
        /// This constructor will mainly be used by the constructor of FrameCollection
        /// to create an instance of a Frame.
        /// </summary>
        /// <param name="domContainer">The domContainer</param>
        /// <param name="frameDocument">The document within the frame</param>
        public Frame(DomContainer domContainer, INativeDocument frameDocument)
            : base(domContainer)
        {
            if (frameDocument == null)
            {
                throw new ArgumentNullException("frameDocument");
            }

            _frameDocument = frameDocument;
            _frameElement  = new Element(domContainer, frameDocument.ContainingFrameElement);
        }
Exemplo n.º 5
0
	    /// <summary>
	    /// This constructor will mainly be used by the constructor of FrameCollection
	    /// to create an instance of a Frame.
	    /// </summary>
	    /// <param name="domContainer">The domContainer</param>
	    /// <param name="frameDocument">The document within the frame</param>
	    /// <param name="parentDocument"> </param>
	    public Frame(DomContainer domContainer, INativeDocument frameDocument, Frame parentDocument)
            : base(domContainer)
		{
	        if (frameDocument == null)
                throw new ArgumentNullException("frameDocument");

            _frameDocument = frameDocument;
            FrameElement = CreateFrameElement(domContainer, frameDocument);

            SetFrameHierarchy(parentDocument, frameDocument);
		}
Exemplo n.º 6
0
        public FrameCollection(DomContainer domContainer, INativeDocument htmlDocument, Document document)
        {
            findBy = Find.Any;

            frames = new List <Frame>();

            foreach (INativeDocument frameDocument in htmlDocument.Frames)
            {
                frames.Add(new Frame(domContainer, frameDocument, document as Frame));
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// This constructor will mainly be used by the constructor of FrameCollection
        /// to create an instance of a Frame.
        /// </summary>
        /// <param name="domContainer">The domContainer</param>
        /// <param name="frameDocument">The document within the frame</param>
        /// <param name="parentDocument"> </param>
        public Frame(DomContainer domContainer, INativeDocument frameDocument, Frame parentDocument)
            : base(domContainer)
        {
            if (frameDocument == null)
            {
                throw new ArgumentNullException("frameDocument");
            }

            _frameDocument = frameDocument;
            FrameElement   = CreateFrameElement(domContainer, frameDocument);

            SetFrameHierarchy(parentDocument, frameDocument);
        }
Exemplo n.º 8
0
        /// <summary>
        /// This is done to facilitate CSS selector look up in IEElementCollection
        /// </summary>
        /// <param name="parentDocument"> </param>
        /// <param name="frameDocument"> </param>
        private void SetFrameHierarchy(Frame parentDocument, INativeDocument frameDocument)
        {
            var nameOrId  = GetFrameElementNameOrId(FrameElement);
            var hierarchy = string.Empty;

            if (parentDocument != null)
            {
                var frameElement = parentDocument.FrameElement;
                hierarchy = frameElement.GetAttributeValue("data-watinFrameHierarchy") + ".";
            }

            hierarchy = hierarchy + nameOrId;

            FrameElement.SetAttributeValue("data-watinFrameHierarchy", hierarchy);
            frameDocument.RunScript(frameDocument.JavaScriptVariableName + ".___WATINFRAMEHIERARCHY = '" + hierarchy + "'", "javascript");
        }
        /// <summary>
        /// This method must be called by its inheritor to dispose references
        /// to internal resources.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (IsDisposed)
            {
                return;
            }

            _nativeDocument = null;
            if (DialogWatcher != null)
            {
                DialogWatcher.DecreaseReferenceCount();
                DialogWatcher = null;
            }
            IsDisposed = true;

            base.Dispose(true);
        }
Exemplo n.º 10
0
	    /// <summary>
	    /// This is done to facilitate CSS selector look up in IEElementCollection
	    /// </summary>
	    /// <param name="parentDocument"> </param>
	    /// <param name="frameDocument"> </param>
	    private void SetFrameHierarchy(Frame parentDocument, INativeDocument frameDocument)
	    {

            var nameOrId = GetFrameElementNameOrId(FrameElement);
	        var hierarchy = string.Empty;

            if (parentDocument != null)
            {
                var frameElement = parentDocument.FrameElement;
                hierarchy = frameElement.GetAttributeValue("data-watinFrameHierarchy") + ".";
            }

	        hierarchy = hierarchy + nameOrId;
	        
            FrameElement.SetAttributeValue("data-watinFrameHierarchy", hierarchy);
            frameDocument.RunScript(frameDocument.JavaScriptVariableName + ".___WATINFRAMEHIERARCHY = '" + hierarchy + "'", "javascript");
	    }
Exemplo n.º 11
0
        /// <summary>
        /// This method must be called by its inheritor to dispose references
        /// to internal resources.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (IsDisposed) return;

            _nativeDocument = null;
            if (DialogWatcher != null)
            {
                DialogWatcher.DecreaseReferenceCount();
                DialogWatcher = null;
            }
            IsDisposed = true;

            base.Dispose(true);
        }
Exemplo n.º 12
0
 public TestDocument(DomContainer container, INativeDocument document)
     : base(container)
 {
     this.document = document;
 }
Exemplo n.º 13
0
 public TestDocument(DomContainer container, INativeDocument document)
     : base(container)
 {
     this.document = document;
 }
Exemplo n.º 14
0
 private static Element CreateFrameElement(DomContainer domContainer, INativeDocument frameDocument)
 {
     return(new Element(domContainer, frameDocument.ContainingFrameElement));
 }
Exemplo n.º 15
0
	    private static Element CreateFrameElement(DomContainer domContainer, INativeDocument frameDocument)
	    {
	        return new Element(domContainer, frameDocument.ContainingFrameElement);
	    }