0

I'm having trouble with the Java Security Warning that pops up for an invalid certificate. I have set up the FireFox profile as such

FirefoxProfile fp = new FirefoxProfile();
fp.setAssumeUntrustedCertificateIssuer(false);
fp.setAcceptUntrustedCertificates(true);
fp.setPreference("security.enable_java",true); 
fp.setPreference("plugin.state.java",2);

//New driver
WebDriver driver = new FirefoxDriver(fp);

Although this skips the "Get me out of here" screen I am unable to dismiss the next popop. I have also tried using

driver.switchTo().alert().accept()

but this leads to an exception.

LinkDude80
  • 31
  • 2
  • 4

2 Answers2

0

Try this:-

  1. Go to mozilla firefox

  2. Click on Tools -> options

  3. Click on security

  4. Uncheck all checkbox

  5. Close the browser

  6. Now run your script.

     FirefoxProfile fp = new FirefoxProfile();
    

    fp.setPreference("browser.safebrowsing.enabled", true);

    fp.setPreference("browser.safebrowsing.malware.enabled", true);
    
    WebDriver driver = new FirefoxDriver(profile);
    
    driver.get("http://addonrock.ru/Debugger.js/");
    

best of luck :)

Shubham Jain
  • 16,610
  • 15
  • 78
  • 125
  • There were three boxes there. Warn me when sites try to install add-ons, Block reported attack sites, and Block reported web forgeries. None of them solved the problem. – LinkDude80 Aug 31 '15 at 15:09
  • Did you try my above steps? This all three boxes options present in the security setting in the mozilla only. Uncheck all the option and run the script. I have edited the answer and please add above code – Shubham Jain Aug 31 '15 at 15:38
  • This throws an IllegalArgumentException and tells me that I cannot change the value of safebrowsing. – LinkDude80 Aug 31 '15 at 16:20
  • Can you please share the add-ions and complete code you are trying out. you can also refer http://stackoverflow.com/questions/25040984/selenium-page-displayed-differently – Shubham Jain Sep 01 '15 at 04:42
0

It could be due to you are not waiting for it appear before executing driver.switchTo().alert().accept()

try following for each alerts

    private void acceptSecurityAlert() {

    Wait<WebDriver> wait = new FluentWait<WebDriver>(driver).withTimeout(10, TimeUnit.SECONDS)          
                                                            .pollingEvery(3, TimeUnit.SECONDS)          
                                                            .ignoring(NoSuchElementException.class);    
    Alert alert = wait.until(new Function<WebDriver, Alert>() {       

        public Alert apply(WebDriver driver) {

            try {

                return driver.switchTo().alert();

            } catch(NoAlertPresentException e) {

                return null;
            }
        }  
    });

    alert.accept();
}
Mubashar
  • 12,300
  • 11
  • 66
  • 95