使用 Chrome 驱动程序未找到警报

No Alert Found using Chrome Driver

使用ChromeDriver 2.14、selenium server 2.47.1 和Chrome 45. 我正在尝试处理基本身份验证提示。我已尝试使用以下代码来尝试解决此问题。

var wait = new OpenQA.Selenium.Support.UI.WebDriverWait(Driver.Value, new TimeSpan(0,0,60)).Until(OpenQA.Selenium.Support.UI.ExpectedConditions.AlertIsPresent());
Driver.Value.SwitchTo().Alert().Dismiss();

还有这个

Driver.Value.SwitchTo().Alert().SetAuthenticationCredentials("test", "test");

还有这个

        while (true)
        {
            try
            {
                Driver.Value.SwitchTo().Alert().SetAuthenticationCredentials("test", "test");
                break; //this is brute force I know
            }
            catch 
            {
                Thread.Sleep(100);
            }
        }

运气不好,他们都抛出一个"no alert found"异常。我们会切换到 firefox,但它是一个内部应用程序,我们只支持 IE 或 Chrome.

我找不到通过基本身份验证提示使用 Selenium 内部身份验证选项的方法。相反,我发现如果你 运行 fiddler 在后台,你可以让它在基于特定站点的提示时自动为你进行身份验证。然后弹出窗口永远不会出现,你的 Selenium 脚本 运行 就好了。