【发布时间】:2018-04-18 10:48:11
【问题描述】:
我正在使用 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 在地址栏中显示一个带有红色删除线的锁定图标 红色删除线图标,
但在用户名文本框附近没有出现味精:
“此连接不安全。此处输入的登录信息可能会被盗用。了解更多”(正如您在重复问题中所写),
那么也许有不同的问题?
【问题讨论】:
标签: c# firefox selenium-webdriver ssl-certificate