示例#1
0
        /// <summary>
        /// Execute javascript in the browser to navigate to the passed in URL if one is provided otherwise navigate to the URL in the app.config
        /// </summary>
        /// <param name="url">URL.</param>
        /// <param name="urlOverride">If set to <c>true</c> URL override.</param>
        public void JSNavigate(string url = "", bool urlOverride = false)
        {
            Logger.Info("Using custom javascript to navigate");
            string expectedPageTitle = "";

            if (url == "" && !urlOverride)
            {
                url = BaseConfiguration.GetUrlValue("app");
                if (BaseConfiguration.Base == WebEnvironment.Dev)
                {
                    expectedPageTitle = ExpectedPageTitles.DevApp;
                }
            }
            else if (url == "" && urlOverride)
            {
                throw new Exception("You must secify a URL as a parameter if you're going to override the base URL");
            }
            else if (url != "" && !urlOverride)
            {
                string page = url;
                url = BaseConfiguration.GetUrlValue(page);
            }
            ExecuteCustomJavaScript(string.Format("window.location.href = '{0}';", url));
            if (expectedPageTitle != "")
            {
                WaitForPageTitleToBe(expectedPageTitle);
            }
            Logger.Info("Successfully navigated to: " + url);
        }
 public CreateAccountPage(BasePage basePage, bool shouldNavigate = false)
 {
     Base = basePage;
     //PageFactoryNg.InitNgWebElements(Base.NgDriver, this);
     NewUserPageElements = new List <NgWebElement>
     {
         FirstName,
         LastName,
         NewPassword
     };
     Base.NgDriver.IgnoreSynchronization = true;
     if (shouldNavigate)
     {
         Base.NavigateTo(BaseConfiguration.GetUrlValue("register"));
     }
     Logger.Info("Waiting for page to open");
     Base.IsPageTitle(AssertValues.RegisterTitle);
     Logger.Info("Page successfully opened");
 }
示例#3
0
        //Under the assumption that the BasePage is always created first for every test, this constructor is used to instantiate universal objects,
        // and execute universal logic (such as navigating to an app url), or even logging in.
        public BasePage(bool shouldNavigateToBaseUrl = true, LoginType loginType = LoginType.AnyUser)
        {
            LoginType = loginType;
            Value     = new BsonDocumentValues(Mongo);
            SetEmailAddress();
            Logger = LogManager.GetCurrentClassLogger();
            Logger.Info("Tests being run on: " + BaseConfiguration.Base);
            SocialCredentials = new SocialCredentials(this);

            if (shouldNavigateToBaseUrl)
            {
                try
                {
                    NgDriver.Navigate().GoToUrl(BaseConfiguration.GetUrlValue());
                    Thread.Sleep(1000);
                }
                catch
                {
                    JSNavigate();
                    Thread.Sleep(1000);
                }
            }
        }