Firefox的硒webdriver给“不安全的连接” [英] Firefox selenium webdriver gives "Insecure Connection"
问题描述
我用Selenium Webdriver(java)创建了20个测试的Maven项目。现在,当我想执行我的Maven项目时,有时会出现以下错误:
- 现在,通过Selenium的脚本在
用户名
输入字段中输入用户名和不安全
弹出窗口覆盖密码
输入字段。 您尝试调用 - 创建一个新的Mozilla Firefox配置文件。你会发现文档这里一>。例如,我已经创建了一个名为
debanjan
的Firefox配置文件 - 配置Firefox配置文件
debanjan
忽略所有
UntrustedCertificate
问题。
- 重新运行您的测试脚本,没有任何问题。 $ b
下面是一个示例代码块,用于禁用
insecure_field_warning
:
System.setProperty(webdriver.gecko.driver,C:\\ Utility \\BrowserDrivers\\geckodriver.exe);
ProfilesIni profile = new ProfilesIni();
FirefoxProfile testprofile = profile.getProfile(debanjan);
testprofile.setAcceptUntrustedCertificates(true);
testprofile.setAssumeUntrustedCertificateIssuer(true);
testprofile.setPreference(security.insecure_field_warning.contextual.enabled,false);
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(FirefoxDriver.PROFILE,testprofile);
dc.setCapability(marionette,true);
WebDriver driver = new FirefoxDriver(dc);
driver.manage()。window()。maximize();
driver.navigate()。(http://demosite.center/wordpress/wp-login.php);
- The URL/Connection with which you are a working if it is
Not Secure
then whenever you access the URL through Mozilla Firefox 53.0, Firefox will display a lock icon with red strike-through red strikethrough icon in the address bar. Now when URL gets loaded the cursor by default will be positioned onUsername
field and there will be popup showing a messageThis connection is not secure. Logins entered here could be compromised. Learn More
like this: - Now your script through Selenium enters the username within the
Username
input field and theNot Secure
popup overlays thePassword
input field. - Next if you try to call the
click()
orsendKeys()
operation in thePassword
input field theNot Secure
popup receives the click andInsecure password warning in Firefox
page opens up in the next tab along with Selenium shifting its focus to new tab. Hence test-case starts Failing. - Create a new Mozilla Firefox Profile. You will find the documentation here. For Example, I have created a Firefox Profile by the name
debanjan
- Configure the Firefox Profile
debanjan
to ignore all theUntrustedCertificate
issues. - Rerun your Test Script without any issues.
Here is a sample code block to disable
insecure_field_warning
:System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe"); ProfilesIni profile = new ProfilesIni(); FirefoxProfile testprofile = profile.getProfile("debanjan"); testprofile.setAcceptUntrustedCertificates(true); testprofile.setAssumeUntrustedCertificateIssuer(true); testprofile.setPreference("security.insecure_field_warning.contextual.enabled", false); DesiredCapabilities dc = DesiredCapabilities.firefox(); dc.setCapability(FirefoxDriver.PROFILE, testprofile); dc.setCapability("marionette", true); WebDriver driver = new FirefoxDriver(dc); driver.manage().window().maximize(); driver.navigate().to("http://demosite.center/wordpress/wp-login.php");
点击()
或 sendKeys()
code>输入字段不安全
弹出窗口接收点击和 解决方案:
在这些情况下,最好的解决方案是:
让我知道这个答案是否是您的问题。
I've created a Maven project with 20 tests made with Selenium Webdriver (java). Now, when I want to execute my Maven project, I get sometimes the following error:
This is due to login every test. So, when I want to run 20 tests, sometimes that error appears and I can't continue my test, so it returns "Failed test" in Selenium Webdriver.
Does anybody know how to fix this problem? I've tried to put "Thread.sleep(30000);" at the end of every test to give them some time "not to seem a robot", but it doesn't work...
Thanks so much for your help guys!
Here is the Answer to your Question:
The Real Issue:
Solution:
In these cases the best solution is:
Let me know if this Answers your Question.
这篇关于Firefox的硒webdriver给“不安全的连接”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!