Ejemplo n.º 1
0
        /// <summary>
        /// Accept default alert
        /// This simple alert displays some information or warning on the screen.
        /// </summary>
        /// <returns>True if alert clicked ok, false otherwise</returns>
        public bool AcceptAlert()
        {
            bool AcceptAlertOk = false;

            try
            {
                string CurrHandle = GetCurrentWindowHandle();

                if (IsAlertPresent())
                {
                    IAlert alert = BaseWebDriver.SwitchTo().Alert();

                    alert.Accept();

                    BaseWebDriver.SwitchTo().Window(CurrHandle);

                    AcceptAlertOk = true;
                }
            }
            catch (Exception)
            {
                AcceptAlertOk = false;
            }
            return(AcceptAlertOk);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Checks to see if an alert is present
 /// </summary>
 /// <returns></returns>
 public bool IsAlertPresent()
 {
     try
     {
         BaseWebDriver.SwitchTo().Alert();
         return(true);
     }
     catch (NoAlertPresentException)
     {
         return(false);
     }
 }