我正在用 编写测试 Selenium + C# 我面临一个重要问题,因为我在使用安全连接 ( HTTPS ) 测试我的网站时没有找到解决方案。我在 stackoverflow 上找到的所有解决方案都已过时或不起作用。
我尝试从以下问题中练习所有解决方案:
Selenium Why setting acceptuntrustedcertificates to true for firefox driver doesn't work?
但他们没有帮我解决问题
也不是使用 Nightly FireFox 的解决方案。
尽管如此,当 selenium 加载 Firfox 浏览器时,我看到页面:“您的连接不安全”。
配置:
我的代码是:
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 在地址栏中显示一个带有红色删除线红色删除线图标的锁定图标,
但在用户名文本框附近没有出现消息:
“此连接不安全。在此处输入的登录信息可能会受到损害。了解更多信息”(如您在重复问题中所写),
那么也许有一个不同的问题?
最佳答案
您正在设置配置文件的属性。 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/