【问题标题】:How to handle "Your connection is not secure" error in firefox using selenium如何使用 selenium 在 Firefox 中处理“您的连接不安全”错误
【发布时间】:2017-05-08 20:32:43
【问题描述】:

我正在使用 webdriver V 3.0.1 和 firefox V 46。我正面临“您的连接不安全”的错误。

请帮助我克服这个问题。您可以在下面找到我的代码

    System.setProperty("webdriver.gecko.driver","D:\\Software\\Webdriver\\gecko new\\geckodriver-v0.11.1-win64\\geckodriver.exe");
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("network.proxy.type", 0);
    profile.setAcceptUntrustedCertificates(true); 
    profile.setAssumeUntrustedCertificateIssuer(false);
    WebDriver driver = new FirefoxDriver(profile);
    driver.get("http://qa.applications.marykayintouch.com/Login/Login.aspx");

【问题讨论】:

  • 在浏览器中,您的 URL 显示为 https 并在您的代码中显示为 http 。为什么会这样?
  • 默认改为https。应用程序启动成功并返回不安全页面。
  • 我尝试了此页面上建议的所有解决方案,但运气不好。我正在使用 Webdriver 3.0.1 和 firefox 浏览器 V 50.1.0。我可以导航到常见的网站,如 google、facebook、Gmail。但是下面提到的 URL 不是导航“qa.applications.marykayintouch.com/Login/Login.aspx”。手动它工作正常。请帮助我
  • @Ashok 你找到解决方案了吗?

标签: java selenium firefox webdriver


【解决方案1】:

对我来说,最简单有效的解决方案就是这样做

var options = new FirefoxOptions()
{
    AcceptInsecureCertificates = true
};

using (var driver = new FirefoxDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), options))
{
    // Your code
}

我尝试使用 Sanjay Bhimani 的示例,但它不起作用,因此查看了可用的构造函数并最终得到了上述代码。

【讨论】:

    【解决方案2】:

    似乎 SSLCertificates 错误 试试编辑功能

    ProfilesIni profiles = new ProfilesIni();
    System.setProperty("webdriver.firefox.profile","custom firefox profile name");
    String browser_profile = System.getProperty("webdriver.firefox.profile");
    FirefoxProfile profile = profiles.getProfile(browser_profile); 
    profile.setAcceptUntrustedCertificates (true); 
    webdriver = new FirefoxDriver(profile); 
    

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    driver = new FirefoxDriver(capabilities);
    

    DesiredCapabilities capabilities = new DesiredCapabilities();
    ProfilesIni profiles = new ProfilesIni();
    System.setProperty("webdriver.firefox.profile","custom firefox profile name");
    String browser_profile = System.getProperty("webdriver.firefox.profile");
    FirefoxProfile profile = profiles.getProfile(browser_profile); 
    profile.setAcceptUntrustedCertificates(true); 
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    capabilities.setCapability(FirefoxDriver.PROFILE, profile);
    webdriver = new FirefoxDriver(capabilities); 
    

    希望它有效。

    【讨论】:

    • 我尝试了此页面上建议的所有解决方案,但运气不好。我正在使用 Webdriver 3.0.1 和 firefox 浏览器 V 50.1.0。我可以导航到常见的网站,如 google、facebook、Gmail。但是下面提到的 URL 不是导航“qa.applications.marykayintouch.com/Login/Login.aspx”。手动它工作正常。请帮助我
    • 我尝试了此页面上建议的所有解决方案,但运气不好。我正在使用 Webdriver 3.0.1 和 firefox 浏览器 V 50.1.0。我可以导航到常见的网站,如 google、facebook、Gmail。但是下面提到的 URL 不是导航“qa.applications.marykayintouch.com/Login/Login.aspx”。手动它工作正常。请帮助我
    【解决方案3】:

    为了在 Firefox 中处理 SSL 证书错误,我们需要使用 Selenium Webdriver 的所需功能并按照以下步骤操作:

    ProfilesIni allProfiles = new ProfilesIni();
    System.setProperty("webdriver.firefox.profile","your custom firefox profile name");
    String browserProfile = stem.getProperty("webdriver.firefox.profile");
    FirefoxProfile profile = allProfiles.getProfile(browserProfile); 
    profile.setAcceptUntrustedCertificates (true); 
    webdriver = new FirefoxDriver(profile); 
    

    您可以参考以下内容: Handling UntrustedSSLcertificates using WebDriver

    【讨论】:

    • 我尝试了此页面上建议的所有解决方案,但运气不好。我正在使用 Webdriver 3.0.1 和 firefox 浏览器 V 50.1.0。我可以导航到常见的网站,如 google、facebook、Gmail。但下面提到的 URL 不是导航“qa.applications.marykayintouch.com/Login/Login.aspx”。手动它工作正常。请帮助我
    猜你喜欢
    • 2012-07-25
    • 2018-10-23
    • 2017-03-20
    • 1970-01-01
    • 2017-11-26
    • 2023-04-09
    • 2018-04-18
    • 2014-08-10
    • 1970-01-01
    相关资源
    最近更新 更多