Firefox selenium webdriver gives “Insecure Connection”

前端 未结 1 1929
日久生厌
日久生厌 2020-12-22 03:16

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:

M

相关标签:
1条回答
  • 2020-12-22 03:45

    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.

    0 讨论(0)
提交回复
热议问题