Firefox selenium webdriver提供“不安全连接”
我用Selenium Webdriver(java)创建了一个包含20个测试的Maven项目。 现在,当我想执行我的Maven项目时,有时会出现以下错误:
Mozilla错误
这是因为每次测试都要登录。 因此,当我想运行20个测试时,有时会出现错误而我无法继续测试,因此它会在Selenium Webdriver中返回“Failed test”。
有人知道如何解决这个问题吗? 我试过把“Thread.sleep(30000);” 在每次测试结束时给他们一些时间“不要看起来像机器人”,但它不起作用……
非常感谢你的帮助!
以下是您的问题的答案:
真实问题:
- 如果它不安全,您使用的URL /连接,那么无论何时通过Mozilla Firefox 53.0访问URL,Firefox都会在地址栏中显示带有红色透视红色删除线图标的锁定图标。 现在,当URL被加载时,默认情况下,光标将位于“
Username
字段上,弹出窗口将显示一条消息This connection is not secure. Logins entered here could be compromised. Learn More
This connection is not secure. Logins entered here could be compromised. Learn More
This connection is not secure. Logins entered here could be compromised. Learn More
如下:
- 现在,您通过Selenium的脚本在
Username
输入字段中输入用户名,而Not Secure
弹出窗口则覆盖Password
输入字段。 - 接下来,如果您尝试在
Password
输入字段中调用click()
或sendKeys()
操作,则“Insecure password warning in Firefox
弹出窗口将收到点击,并在下一个选项卡中打开Insecure password warning in Firefox
页面中的Insecure password warning in Firefox
以及Selenium将其焦点移至新选项卡。 因此测试用例开始失败 。
解:
在这些情况下,最好的解决方案是:
- 创建一个新的Mozilla Firefox配置文件。 你会在这里找到文档 。 例如,我创建了一个名为
debanjan
的Firefox配置文件 - 配置Firefox配置文件
debanjan
以忽略所有UntrustedCertificate
问题。 - 重新运行您的测试脚本没有任何问题。
-
以下是禁用
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");
如果这回答你的问题,请告诉我。
- Selenium WebDriver鼠标操作moveToElement不会在Firefox Linux上引发mouseout事件
- Selenium Webdriver:在firefox中抑制不受信任的连接消息
- 无法使用IEDriver单击IE上的链接
- 如何调试Firefox警报框自动关闭并且无法检测Serenity BDD中的警报?
- 通过selenium在firefox中打开私有模式
- 如何在Java applet中正确指定代码库和存档?
- 如何使用FirefoxProfile通过Firefox浏览器自动下载?
- 来自Selenium 2 / WebDriver的Id的jQuery元素选择器
- 45000 ms后无法在端口7055上连接到主机127.0.0.1。 用FF版26.0和selenium独立jar2.39