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);
        }
Example #2
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");
        }
Example #3
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");
	    }