Example #1
0
        /// <summary>
        /// 还原当前页面SESSION
        /// </summary>
        static public void RestorePageSession(this Browser browser)
        {
            RequireJQueryInstall(browser);
            string fileName = browser.Uri.Host;

            fileName = Path.Combine(Environment.GetFolderPath(
                                        Environment.SpecialFolder.ApplicationData), string.Format("{0}.session", fileName));
            StreamReader sw      = null;
            string       session = "";

            if (!File.Exists(fileName))
            {
                return;
            }
            try
            {
                sw      = new StreamReader(fileName);
                session = sw.ReadToEnd();
            }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                }
            }

            string code = @"
                    var obj = " + session + @";
                          
                    return obj.url;       
                ";
            object url  = JS.FunEval(browser, code);

            if (url != null)
            {
                //先打开原始页面
                browser.GoTo(url.ToString());
                //回复FORM内容
                code = @"
                    var obj =" + session + @";
                    $jq('form').deserialize(obj.form);                          
                   ";
                IEUtils.RunScript(code, GetWindows(browser));
                browser.AttachToIE();
            }
        }
Example #2
0
 public void Visit(string url)
 {
     Watin.GoTo(url);
 }