Exemplo n.º 1
0
        /// <summary>
        /// 渲染页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void Handler_Load(object sender, EventArgs e)
        {
            var callIndex = Request.QueryString["CallIndex"];

            if (callIndex != "login")
            {
                if (string.IsNullOrEmpty(Utils.GetCookie("IsLogin")))
                {
                    Response.Redirect("Login.html");
                    // Response.End();
                }
                else if (callIndex != "home")
                {
                    string userName = Framework.Common.Utils.GetCookie("userid");
                    if (!CanRedirect(callIndex, userName))
                    {
                        Response.Redirect("~/html/403.htm");
                        // Response.End();
                    }
                }
            }
            var page = new PageCore(callIndex);

            TemplateFile = page._TemplateFile;
            TemplateData = page._TemplateData;
        }
Exemplo n.º 2
0
        public void GoToNewPage(string pageAlias)
        {
            string   targetPage  = Alias.ResolveAsString(pageAlias);
            PageCore currentPage = ScenarioContext.Current.Page();

            Assert.IsTrue(currentPage.Url.Equals(targetPage), string.Format("Пользователь не перешел на страницу '{0}'.", targetPage));
        }
Exemplo n.º 3
0
        public void SelectRegion(string fromAlias, string toAlias)
        {
            PageCore currentPage = ScenarioContext.Current.Page();

            string      fromXPath = Alias.ResolveAsString(fromAlias);
            PageElement from      = currentPage.FindElement(fromXPath);

            string      toXPath = Alias.ResolveAsString(toAlias);
            PageElement to      = currentPage.FindElement(toXPath);

            from.MoveMouseTo(1, 1);
            from.MouseDown(1, 1);

            //to.MoveMouseTo(2, 2);
            to.MouseUp(1, 1);
        }
Exemplo n.º 4
0
        public void OpenPage(string pageAlias)
        {
            if ((IWebDriver)ScenarioContext.Current["Driver"] == null)
            {
                throw new InvalidOperationException("ScenarioContext.Current[\"Driver\"] is null");
            }

            PageCore page = null;

            page = PageCore.TryResolveAsPage(pageAlias);
            if (page == null)// && a != null)
            {
                page = new PageCore();
                string url = Alias.ResolveAsString(pageAlias);
                page.StartUrl = url;
            }

            ScenarioContext.Current.SetPage(page);

            page.Open();
        }
Exemplo n.º 5
0
 /// <summary>
 /// 渲染页面
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public override void Handler_Load(object sender, EventArgs e)
 {
     var callIndex = Request.QueryString["CallIndex"];
     if (callIndex != "login")
     {
         if (string.IsNullOrEmpty(Utils.GetCookie("IsLogin")))
         {
             Response.Redirect("Login.html");
            // Response.End();
         }
         else if(callIndex != "home")
         {
             string userName = Framework.Common.Utils.GetCookie("userid");
             if (!CanRedirect(callIndex, userName))
             {
                 Response.Redirect("~/html/403.htm");
                // Response.End();
             }
         }
     }
     var page = new PageCore(callIndex);
     TemplateFile = page._TemplateFile;
     TemplateData = page._TemplateData;
 }
Exemplo n.º 6
0
        /// <summary>
        /// 渲染页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void Handler_Load(object sender, EventArgs e)
        {
            string callIndex = Request.QueryString["CallIndex"];

            if (callIndex != "login")
            {
                if (string.IsNullOrEmpty(GetCookie("islogin")) || callIndex == null)
                {
                    Response.Redirect("Login.html");
                    Response.End();
                }
                //else
                //{
                //    string key = Utils.GetCookie("userid");
                //    bool verify = false;
                //    string url = Request.RawUrl.Replace('/', ' ').Trim();
                //    if (url == "index.html" || url == "login.html")
                //    {
                //        verify = true;
                //    }
                //    else
                //    {
                //        List<string> menulist = NTS.WEB.Common.CacheHelper.GetCache(key) as List<string>;
                //        if (menulist != null)
                //        {
                //            if (menulist.Contains(url))
                //            {
                //                verify = true;
                //            }
                //        }
                //    }
                //    if(verify==false)
                //    {

                //        Response.Redirect("Login.html");
                //        Response.End();
                //    }
                //}
            }

            var page = new PageCore(callIndex);

            TemplateFile = page._TemplateFile;
            TemplateData = page._TemplateData;


            string key    = Utils.GetCookie("userid");
            bool   verify = false;
            string url    = Request.RawUrl.Replace('/', ' ').Trim().ToLower().Split('?')[0];

            if (url == "login.html")
            {
                verify = true;
            }
            else
            {
                List <string> menulist = NTS.WEB.Common.CacheHelper.GetCache(key) as List <string>;

                if (menulist != null)
                {
                    if (menulist.Contains(url))
                    {
                        verify = true;
                    }
                }
                else
                {
                    Response.Redirect("Login.html");
                    Response.End();
                }
            }
            if (verify == false)
            {
                Response.Write("<script>alert('您没有权限访问该页面');</script>");
                Response.Write("<script language='javascript'>window.parent.location.href='login.html';</script>");
            }
        }
Exemplo n.º 7
0
        public static void AgreeWithConfirm()
        {
            PageCore page = ScenarioContext.Current.Page();

            page.Driver.SwitchTo().Alert().Accept();
        }
Exemplo n.º 8
0
        public void RefreshWindow()
        {
            PageCore currentPage = ScenarioContext.Current.Page();

            currentPage.Refresh();
        }
Exemplo n.º 9
0
        public void MaximizePageWindow()
        {
            PageCore currentPage = ScenarioContext.Current.Page();

            currentPage.MaximizeWindow();
        }
Exemplo n.º 10
0
        public void MovePageWindowTo(int x, int y)
        {
            PageCore currentPage = ScenarioContext.Current.Page();

            currentPage.MoveWindowTo(x, y);
        }
Exemplo n.º 11
0
        public void SetPageSize(int width, int height)
        {
            PageCore currentPage = ScenarioContext.Current.Page();

            currentPage.SetWindowSize(width, height);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 渲染页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void Handler_Load(object sender, EventArgs e)
        {
            string callIndex = Request.QueryString["CallIndex"];

            if (callIndex != "login")
            {

                if (string.IsNullOrEmpty(GetCookie("islogin")) || callIndex == null  )
                {
                    Response.Redirect("Login.html");
                    Response.End();
                }
                //else
                //{
                //    string key = Utils.GetCookie("userid");
                //    bool verify = false;
                //    string url = Request.RawUrl.Replace('/', ' ').Trim();
                //    if (url == "index.html" || url == "login.html")
                //    {
                //        verify = true;
                //    }
                //    else
                //    {
                //        List<string> menulist = NTS.WEB.Common.CacheHelper.GetCache(key) as List<string>;
                //        if (menulist != null)
                //        {
                //            if (menulist.Contains(url))
                //            {
                //                verify = true;
                //            }
                //        }
                //    }
                //    if(verify==false)
                //    {

                //        Response.Redirect("Login.html");
                //        Response.End();
                //    }
                //}
            }

            var page = new PageCore(callIndex);
            TemplateFile = page._TemplateFile;
            TemplateData = page._TemplateData;

            string key = Utils.GetCookie("userid");
            bool verify = false;
            string url = Request.RawUrl.Replace('/', ' ').Trim().ToLower().Split('?')[0];
            if (  url == "login.html")
            {
                verify = true;
            }
            else
            {
                List<string> menulist = NTS.WEB.Common.CacheHelper.GetCache(key) as List<string>;

                if (menulist != null)
                {
                    if (menulist.Contains(url))
                    {
                        verify = true;
                    }
                }
                else
                {
                    Response.Redirect("Login.html");
                    Response.End();
                }
            }
            if (verify == false)
            {

                Response.Write("<script>alert('您没有权限访问该页面');</script>");
                Response.Write("<script language='javascript'>window.parent.location.href='login.html';</script>");

            }
        }