我正在开发一些硒测试,我面临一个重要问题,因为当我使用安全连接( HTTPS )测试我的网站时,我没有找到“真正的”解决方案。我在stackoverflow上找到的所有解决方案都已过期或无效:
我唯一的解决方法是使用github上指示的每晚mozilla版本:https://github.com/mozilla/geckodriver/issues/420
private IWebDriver driver;
private string baseURL;
private FirefoxOptions ffOptions;
private IWait<IWebDriver> wait;
[SetUp]
public void SetupTest()
{
ffOptions = new FirefoxOptions();
ffOptions.BrowserExecutableLocation = @"D:\AppData\Local\Nightly\firefox.exe";
FirefoxProfile profile = new FirefoxProfile();
profile.AssumeUntrustedCertificateIssuer = false;
profile.AcceptUntrustedCertificates = true;
ffOptions.Profile = profile;
ffOptions.LogLevel = FirefoxDriverLogLevel.Info;
driver = new FirefoxDriver(FirefoxDriverService.CreateDefaultService(), ffOptions, TimeSpan.FromSeconds(30));
//[...]
}
配置:
有没有人有避免使用夜间释放的解决方案?
有关信息,由于我的互联网政策,我只能访问stackoverflow和github,请不要建议我使用chrome!
感谢您的帮助!
答案 0 :(得分:1)
是的,它是geckodriver的一个错误。你可以找到它here!
答案 1 :(得分:0)
在 AcceptInsecureCertificates
中将 true
属性设置为 FirefoxOptions
为我解决了这个问题。这是更改后我的初始化的样子:
var profile = new FirefoxProfile();
profile.DeleteAfterUse = true;
profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", LocalURL);
profile.SetPreference("network.automatic-ntlm-auth.allow-non-fqdn", true);
profile.SetPreference("webdriver_accept_untrusted_certs", true);
// Only setting this property to true did not work for me either
profile.AcceptUntrustedCertificates = true;
profile.AssumeUntrustedCertificateIssuer = false;
return new FirefoxDriver(new FirefoxOptions
{
Profile = profile,
// When I also added this line, it DID work
AcceptInsecureCertificates = true
});