Firefox的硒webdriver给“不安全的连接” [英] Firefox selenium webdriver gives "Insecure Connection"

查看:203
本文介绍了Firefox的硒webdriver给“不安全的连接”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用Selenium Webdriver(java)创建了20个测试的Maven项目。现在,当我想执行我的Maven项目时,有时会出现以下错误:


  1. 现在,通过Selenium的脚本在用户名输入字段中输入用户名和不安全弹出窗口覆盖密码输入字段。
  2. 您尝试调用点击() sendKeys() code>输入字段不安全弹出窗口接收点击和


    解决方案:



    在这些情况下,最好的解决方案是:


    1. 创建一个新的Mozilla Firefox配置文件。你会发现文档这里。例如,我已经创建了一个名为 debanjan
    2. 的Firefox配置文件
    3. 配置Firefox配置文件 debanjan 忽略所有 UntrustedCertificate 问题。
    4. 重新运行您的测试脚本,没有任何问题。 $ b
    5. 下面是一个示例代码块,用于禁用 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);


    让我知道这个答案是否是您的问题。

    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:

    Mozilla 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:

    1. 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 on Username field and there will be popup showing a message This connection is not secure. Logins entered here could be compromised. Learn More like this:

    1. Now your script through Selenium enters the username within the Username input field and the Not Secure popup overlays the Password input field.
    2. Next if you try to call the click() or sendKeys() operation in the Password input field the Not Secure popup receives the click and Insecure 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.

    Solution:

    In these cases the best solution is:

    1. Create a new Mozilla Firefox Profile. You will find the documentation here. For Example, I have created a Firefox Profile by the name debanjan
    2. Configure the Firefox Profile debanjan to ignore all the UntrustedCertificate issues.
    3. Rerun your Test Script without any issues.
    4. 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");
      

    Let me know if this Answers your Question.

    这篇关于Firefox的硒webdriver给“不安全的连接”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆