3

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!

UserMB
  • 121
  • 2
  • 13
  • Can you just ignore that message and continue on? – santhosh kumar Jun 23 '17 at 08:41
  • And how could I do that? This is a new tab, it opens and it stops the test. I don't know how to ignore it... – UserMB Jun 23 '17 at 08:50
  • Ok, you mean its not taking to the desired URL but to this page(the image in the question).. Then, can you try updating the browser and driver and check – santhosh kumar Jun 23 '17 at 08:52
  • I tried with: DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability("marionette", true); capabilities.acceptInsecureCerts(); but it still doesn't work. I've updated the browser and nothing new happens. – UserMB Jun 23 '17 at 09:32
  • can you also try without any desired capabilities – santhosh kumar Jun 23 '17 at 09:38
  • yes. actually, at the beginning, I didn't use desired capabilities, but I got the same error. So, I keep trying new ways to solve it. – UserMB Jun 23 '17 at 10:00
  • Is this different behaviour is happening only for the site that u want to test or for all other sites? – santhosh kumar Jun 23 '17 at 10:04
  • This is happening with the only web pages that I want to test. This is the new tab that I get: https://blog.mozilla.org/security/2017/01/20/communicating-the-dangers-of-non-secure-http/ How could I ignore or close that tab (to return to my current login tab) with Selenium Webdriver?? Thanks so much!! – UserMB Jun 23 '17 at 10:24
  • can i have that URL? – santhosh kumar Jun 23 '17 at 10:25
  • It's the page of my job. Although I told you, you need user&password. I've tried writing "httpS:..." in the URL, but it doesn't exist, so it doesn't work neither... – UserMB Jun 23 '17 at 10:46

1 Answers1

2

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:

enter image description here

  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.

enter image description here

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.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352