【问题标题】:Alert didn't work in Chrome driver警报在 Chrome 驱动程序中不起作用
【发布时间】:2018-05-09 22:33:06
【问题描述】:

我正在使用在所有浏览器中都有证书弹出窗口的网站,我使用警报代码示例处理弹出窗口:

            try
            {
                IAlert alert = driver.SwitchTo().Alert();
                if (alert != null)
                {
                    alert.Accept();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
            }

但是当我使用 chrome 驱动程序时,它没有捕捉到警报并抛出异常:

对 URL 的远程 WebDriver 服务器的 HTTP 请求 http://localhost:65505/session/3c3a49f5ea328ffff6cc44effaa8326f/alert_text 60 秒后超时。

弹出图片:

它不是 web html 代码的一部分,所以我在这里缺少什么?

谢谢。

【问题讨论】:

  • 你确定这是一个警报,而不是一个框架?

标签: c# .net selenium selenium-chromedriver


【解决方案1】:

你可以试试下面的代码 sn-p :

driver.SwitchTo().ActiveElement();
System.Windows.Forms.SendKeys.SendWait(@"{ENTER}");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-27
    • 2020-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多