public static IAlert AlertOrNull(this ITargetLocator locator)
 {
     try
     {
         return(locator.Alert());
     }
     catch (NoAlertPresentException)
     {
         return(null);
     }
 }
 public static IAlert?TryGetAlert(this ITargetLocator locator)
 {
     try
     {
         return(locator.Alert());
     }
     catch
     {
         return(null);
     }
 }
 public static IAlert WaitAlert(this ITargetLocator locator, int seconds = 10)
 {
     while (true)
     {
         try { return(locator.Alert()); }
         catch (NoAlertPresentException) when(--seconds >= 0)
         {
             Thread.Sleep(1000);
         }
     }
 }
Exemple #4
0
        public void WindowProcess_Demo3()
        {
            IWebDriver driver = new FirefoxDriver();
            //省略部分代码... ...
            var            oldWinHandle = driver.CurrentWindowHandle;
            ITargetLocator locator      = driver.SwitchTo();
            IAlert         winAlert     = locator.Alert();

            winAlert.Accept();                            //确定:Alert , Confirm, Prompt
            winAlert.Dismiss();                           //取消:Confirm, Prompt
            var text = winAlert.Text;                     //获取提示内容:Alert , Confirm, Prompt

            winAlert.SendKeys("input text.");             //输入提示文本:Prompt

            //后续操作... ...
            driver.Quit();
        }
Exemple #5
0
 public AlertInstance Alert()
 {
     return(new AlertInstance(this.Engine.Object.InstancePrototype, m_targetLocator.Alert()));
 }
 public IAlert Alert()
 {
     lock (m_lock) { return(locator.Alert()); }
 }
Exemple #7
0
 public IAlert Alert()
 {
     return(_targetLocator.Alert());
 }
Exemple #8
0
 public IAlert Alert()
 {
     return(targetLocator_.Alert());
 }
 public IAlert Alert()
 {
     return(_targetLocator.Alert().ToWrapper());
 }