示例#1
0
 public void UpdatePageAttribute(PageAttribute pageAttr)
 {
     if (pageAttr == null)
     {
         return;
     }
     if (!string.IsNullOrEmpty(pageAttr.Url))
     {
         Url = pageAttr.Url;
     }
     if (!string.IsNullOrEmpty(pageAttr.Title))
     {
         Title = pageAttr.Title;
     }
     if (pageAttr.IsCheckUrlSetManual)
     {
         UrlCheckType = pageAttr.UrlCheckType;
     }
     if (pageAttr.IsCheckTitleSetManual)
     {
         TitleCheckType = pageAttr.TitleCheckType;
     }
     if (pageAttr.IsHomePage)
     {
         IsHomePage = true;
     }
 }
示例#2
0
        private bool CheckPageAttribute(PageCheckType checkType, bool throwError, string checkWhat, string actual, string expected)
        {
            if (checkType == PageCheckType.NoCheck)
            {
                return(true);
            }
            if (string.IsNullOrEmpty(expected))
            {
                VISite.Alerting.ThrowError(string.Format("Page '{0}' {1} is empty. Please set {1} for this page",
                                                         Name, checkWhat));
                return(false);
            }
            VISite.Logger.Event(string.Format("Check page '{0}' {1} {2} '{3}'",
                                              Name, checkWhat, checkType == PageCheckType.Equal ? "equal to " : "contains", expected));
            var result =
                (checkType == PageCheckType.Equal)
                    ? actual == expected
                    : actual.Contains(expected);

            if (result)
            {
                return(true);
            }
            var errorMsg = string.Format("Failed to check page {0} '{1}'." +
                                         "Actual:   '{2}'".FromNewLine() +
                                         "Expected: '{3}'".FromNewLine() +
                                         "CheckType: '{4}'", checkWhat, Name, actual, expected, checkType);

            if (throwError)
            {
                throw VISite.Alerting.ThrowError(errorMsg);
            }
            VISite.Logger.Error(errorMsg);
            return(false);
        }
示例#3
0
 public void FillFromPageAttribute(PageAttribute pageAttr)
 {
     if (pageAttr == null)
     {
         return;
     }
     Url            = pageAttr.Url;
     Title          = pageAttr.Title;
     UrlCheckType   = pageAttr.UrlCheckType;
     TitleCheckType = pageAttr.TitleCheckType;
     IsHomePage     = pageAttr.IsHomePage;
 }
示例#4
0
 private void SetEmptyPage()
 {
     if (IsSiteSet)
     {
         Url = "";
     }
     else
     {
         _url = "";
     }
     Title          = "";
     UrlCheckType   = PageCheckType.NoCheck;
     TitleCheckType = PageCheckType.NoCheck;
     IsHomePage     = false;
 }
示例#5
0
 public bool CheckTitle(PageCheckType checkType, bool throwError = false)
 {
     return(CheckPageAttribute(checkType, throwError, "title",
                               WebDriver.Title, Title));
 }
示例#6
0
 public bool CheckUrl(PageCheckType checkType, bool throwError = false)
 {
     return(CheckPageAttribute(checkType, throwError, "url",
                               WebDriver.Url.ToLower().TrimEnd('/'), Url.ToLower().TrimEnd('/')));
 }