0

Security warning observed on Firefox:

The information you have entered on this page will be sent over an insecure connection and could be read by a third party. Are you sure you want to send this information? Click Continue or cancel

To click on continue I have tried using Robot class method

Robot robot =new Robot(); 
robot.keyPress(KeyEvent.VK_LEFT);
robot.keyPress(KeyEvent.VK_ENTER);
System.out.println("key pressed");
robot.keyRelease(KeyEvent.VK_ENTER); 

But I get UnhandledAlertException: Unexpected modal dialog (text: The information you have entered on this page will be sent over an insecure connection and could be read by a third party.

Are you sure you want to send this information?): The information you have entered on this page will be sent over an insecure connection and could be read by a third party.

Are you sure you want to send this information?

I also tried manually clicking on continue , then continue with selenium script 1 Manually close
2 WebElement success = wait.until(ExpectedConditions .visibilityOfElementLocated(By.cssSelector(".error-msg")));

Then i get WebDriver exception that ".error-msg" is not a Web Element

Grishma Oswal
  • 303
  • 1
  • 7
  • 22

1 Answers1

0

Following worked for me in Java

    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