C# 登录弹出窗口和Selenium

C# 登录弹出窗口和Selenium,c#,selenium,http-authentication,C#,Selenium,Http Authentication,我正在尝试访问一个网站以启动Selenium脚本。然而,当我把网站的链接,它弹出一个窗口,要求用户名和密码 我不能用硒做任何事。看看我在代码中尝试了什么,但显然没有成功 有什么想法吗 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using OpenQA.Selenium; using OpenQA.Seleni

我正在尝试访问一个网站以启动Selenium脚本。然而,当我把网站的链接,它弹出一个窗口,要求用户名和密码

我不能用硒做任何事。看看我在代码中尝试了什么,但显然没有成功

有什么想法吗

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
using System.Collections.ObjectModel;
using System.Threading;
using System.IO;
using OpenQA.Selenium.Interactions;

namespace CRMTest1WithSelenium
{
    class Program
    {
        static void Main(string[] args)
        {
            IWebDriver driver = null;
            driver = new FirefoxDriver();
            string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes("USERNAME" + ":" + "Password"));

            String URL = "http://" + credentials+ "@" + "bfaz-testcrm.cloudapp.net/BathfitterCRMTest";

            driver.Navigate().GoToUrl(URL);
            driver.Manage().Window.Maximize();


        }
    }
}

如果您是指HTTP基本身份验证

,您的解决方案写在这里:


您可以使用selenium.actions库来实现这一点。与c#相比,我更喜欢python,但详细信息如下:

这将允许您点击“操作对话框”输入凭据

不幸的是,大多数浏览器现在都有这些问题。例如,使用诸如python请求之类的无头url可以让您绕过它: (很抱歉,响应是用python编写的,但是我认为premiss是相同的)

r=requests.get('https://username:password@domain.com

其中,使用Firefox/Chrome的webdrivers与以下内容类似:
a=driver.get('https://username:password@domain.com')

但是,如果您观看浏览器,它将正确传递URL,但仍会显示下拉列表,其中标准规定它应符合条件


对于http身份验证,操作链是处理此问题的最佳选择。

您是否看到弹出警报或弹出窗口?