Example #1
0
        public static string formatJsCode(this WatiN_IE ie, string codeToFormat)
        {
            if (ie.url().not_Equal("about:blank"))
            {
                "opening ABOUT:Blank".info();
                ie.open("about:blank");
            }
            else
            {
                "already in ABOUT:Blank".info();
            }

            if (ie.js_FunctionExists("js_beautify").isFalse())
            {
                var jsBeautify = @"beautify.js".local();
                ie.eval(jsBeautify.fileContents());
                if (ie.js_FunctionExists("js_beautify"))
                {
                    "Injected beautify.js into about:blank".info();
                }
                else
                {
                    "Failed to Inject js_beautify code".error();
                }
            }
            "formating Javascript with size: {0}".info(codeToFormat.size());
            ie.setJsObject(codeToFormat);
            ie.eval("window.external.setJsObject(js_beautify(_jsObject))");
            var result = ie.getJsObject().str().fix_CRLF();

//			"formated Javascript has size: {0}".info(result.size());
            return(result);
        }
Example #2
0
 public static WatiN_IE      refresh(this WatiN_IE ie)
 {
     if (ie.url().valid())
     {
         ie.open(ie.url());
     }
     return(ie);
 }
Example #3
0
        public static WatiN_IE show_Formated_Javascript(this WatiN_IE ie, WatiN_IE temp_ie, string codeToFormat)
        {
            var prettifyHtml = @"prettify.htm".local();

            if (prettifyHtml.fileExists().isFalse())
            {
                return(ie);
            }

            if (ie.url().isNull() || ie.url().contains("prettify.htm").isFalse())
            {
                ie.open(prettifyHtml);
            }
            var formatedJsCode = (temp_ie.isNull())
                                     ? ie.HostControl.formatJsCode(codeToFormat)
                                     : temp_ie.formatJsCode(codeToFormat);

            var codeDiv = ie.div("codeDiv");

            codeDiv.innerHtml("<pre id=\"code\" class=\"prettyprint\">{0}</pre>".format(formatedJsCode));
            ie.invokeScript("prettyPrint");
            return(ie);
        }
Example #4
0
 public static WatiN_IE open_ASync(this WatiN_IE watinIe, string url)
 {
     O2Thread.mtaThread(() => watinIe.open(url));
     return(watinIe);
 }
Example #5
0
 public static WatiN_IE open(this WatiN_IE watinIe, string url)
 {
     return(watinIe.open(url, 0));
 }
Example #6
0
 public static WatiN_IE set_Html(this WatiN_IE ie, string newHtml)
 {
     ie.open(newHtml.saveWithExtension(".html"));
     return(ie);
 }