protected override void OnPreRender(EventArgs e)
 {
     try
     {
         base.OnPreRender(e);
         AjaxManager.AjaxSettings.AddAjaxSetting(this, ParentPage.pnlErrors);
         if (!Page.ClientScript.IsOnSubmitStatementRegistered(ParentPage.GetType(), "ResizePopUp"))
         {
             this.Page.ClientScript.RegisterOnSubmitStatement(ParentPage.GetType(), "ResizePopUp", "SetPopUpHeight(); try{if(Page_IsValid) this.disabled=true;}catch(e){}");
         }
     }
     catch (IndException exc)
     {
         ShouldContinue = false;
         _ParentGenericUserControl.ReportControlError(exc);
         return;
     }
     catch (Exception ex)
     {
         ShouldContinue = false;
         _ParentGenericUserControl.ReportControlError(new IndException(ex));
         return;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Emulates click on current IWebElement without waiting for the page to load
        /// </summary>
        /// <returns> return value should be ignored </returns>
        private object ClickNoWait(bool waitForItself = true, bool skipPageCreation = false)
        {
            _log.Info(String.Format("Start click: on element {0} from page {1}", Identifier, ParentPage.GetType().FullName));

            if (waitForItself)
            {
                _log.Info(String.Format("performStaleTest = true -> Performing StaleTest before Clicking button {0}", Identifier));
                Until.Element(this).IsNotStale().Wait();
            }

            if (!Element.Displayed)
            {
                _log.Info(String.Format("button.Displayed = false -> Waiting for button to Become Visible before Clicking {0}", Identifier));
                Until.Element(this).BecomesVisible().Wait();
            }

            if (!Element.Enabled)
            {
                _log.Info(String.Format("button.Enabled = false -> Waiting for button to Become Enabled before Clicking {0}", Identifier));
                Until.Element(this).BecomesEnabled().Wait();
            }

            if (!Element.Displayed || !Element.Enabled)
            {
                throw new ConstraintException("Button is not displayed or not enabled !");
            }
            //Until.Element(this.Element).BecomesVisible().Wait();

            _log.Info(String.Format("Clicking -> [{0}]", Identifier));

            if (NextPage == null || skipPageCreation)
            {
                //Actions builder = new Actions(Driver);
                //builder.MoveToElement(this.Element).Click(this.Element).Perform();	//this is to fix: "The point at which the driver is attempting to click on the element was not scrolled into the viewport."
                Element.Click();
            }
            else
            {
                if (Globals.RegisterTrigger(NextPage, this))
                {
                    Globals.TriggerNavigationFor(NextPage);
                }

                _log.Info(String.Format("Before Page {0} instantiation", NextPage.Name));

                BasePage page;

                try
                {
                    page = Activator.CreateInstance(NextPage, ParentPage.Driver, NextPageContainerType, null, ParentContainer) as BasePage;
                }
                catch (UnhandledAlertException e)
                {
                    _log.Info(String.Format("Unhandled Alert Excleption with Text = {0} when pressing button = {1} returning null !", e.AlertText, Identifier));
                    throw;
                }
                finally
                {
                    Globals.UnregisterTrigger(NextPage);
                }

                _log.Info(String.Format("After Page {0} instantiation", NextPage.Name));

                _log.Info(String.Format("Finish click: on element {0} from page {1}", Identifier, ParentPage.GetType().FullName));

                return(page);
            }
            _log.Info(String.Format("Finish click: on element {0} from page {1}", Identifier, ParentPage.GetType().FullName));

            return(null);
        }