c# - 您的连接不安全 - 使用 Selenium.WebDriver v.3.6.0 + Firefox v.56

标签 c# firefox selenium-webdriver ssl-certificate

我正在用 编写测试 Selenium + C# 我面临一个重要问题,因为我在使用安全连接 ( HTTPS ) 测试我的网站时没有找到解决方案。我在 stackoverflow 上找到的所有解决方案都已过时或不起作用。
我尝试从以下问题中练习所有解决方案:
Selenium Why setting acceptuntrustedcertificates to true for firefox driver doesn't work?

但他们没有帮我解决问题
也不是使用 Nightly FireFox 的解决方案。
尽管如此,当 selenium 加载 Firfox 浏览器时,我看到页面:“您的连接不安全”。

配置:

  • 火狐 v56.0
  • Selenium.Firefox.WebDriver v0.19.0
  • Selenium.WebDriver v3.6.0

  • 我的代码是:
                        FirefoxOptions options = new FirefoxOptions();
                        FirefoxProfile profile = new FirefoxProfile();
                        profile.AcceptUntrustedCertificates = true;
                        profile.AssumeUntrustedCertificateIssuer = false;
                        options.Profile = profile;
                        driver = new FirefoxDriver(FirefoxDriverService.CreateDefaultService() , options , TimeSpan.FromSeconds(5));
                        Drivers.Add(Browsers.Firefox.ToString() , driver);
    

    感谢您的帮助!

    在这里更新我的问题:

    注 1:对于将我的问题标记为与此问题重复的任何人:

    Firefox selenium webdriver gives “Insecure Connection”
    我认为这是同样的问题,但我需要 C# 的解决方案,我尝试将您的 JAVA 代码与我上面的代码相匹配

    首先,我将以下语句改为 TRUE:
         profile.AssumeUntrustedCertificateIssuer = true;
    

    其次,我创建了新的 FF 配置文件(“AutomationTestsProfile”)
    并尝试使用它:

    尝试 1:
           FirefoxProfile profile = new FirefoxProfileManager().GetProfile("AutomationTestsProfile");
    

    尝试2:
           FirefoxProfile profile = new FirefoxProfile("AutomationTestsProfile");
    

    我运行 2 个选项,但问题仍然存在。

    注 2:我附上了我的问题的屏幕截图,当驱动程序尝试在登录页面上向用户名输入文本时出现。

    我注意到当我用 FF 打开我的网站时,Firefox 在地址栏中显示一个带有红色删除线红色删除线图标的锁定图标,

    但在用户名文本框附近没有出现消息:

    “此连接不安全。在此处输入的登录信息可能会受到损害。了解更多信息”(如您在重复问题中所写),

    那么也许有一个不同的问题?

    screenshot: "insecure Connection" tab

    最佳答案

    您正在设置配置文件的属性。 FirefoxOptions 有一个属性 AcceptInsecureCertificates,将其设置为 true。

    忘记配置文件,这就是您想要的:

    var op = new FirefoxOptions
    {
        AcceptInsecureCertificates = true
    };
    
    Instance = new FirefoxDriver(op);
    

    关于c# - 您的连接不安全 - 使用 Selenium.WebDriver v.3.6.0 + Firefox v.56,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47134134/

    相关文章:

    c# - Xamarin.forms 中的录音

    JavaScript 不在本地页面上运行

    javascript - 是什么导致 Firefox 上 .mp4 出现 "mix-blend-mode mode"中的错误?

    selenium - 无法使用 Selenium webdriver 访问下拉菜单,为什么?

    c# - Try-catch 不等待内部的异步函数

    c# - 为什么我不能用相同的参数再次调用这个方法? (空引用)

    c# - Html Agility Pack,通过站点搜索指定的字符串

    javascript - 如何检查我的网站的 Firefox 扩展是否安装于 2015 年

    selenium - 如何在 RIDE 中单击单击事件上具有 javascript 的行

    c# - Selenium webdriver c# 等待文本出现