follow me icons

Monday, June 18, 2012

Modal dialog present webdriver Error

To surpress the IE security warning modal dialog present (Selenium::WebDriver::Error::UnhandledAlertError) use the following code

Internet Explorer security warning modal dialog box:

"Do you want to view only the webpage content that was delivered securely? This webpage contains content that will not be delivered using a secure HTTPS connection, which could compromise the security of the entire webpage "

"Internet explorer - This page is accessing information that is not under its control. This poses a security risk. Do you want to continue?" This warning is probably because we are using the IE Standalone selenium webdriver. The workaround for the issue:

begin
   click_link "test"
rescue Selenium::WebDriver::Error:UnhandledAlertError => e
   # may need to use the page.driver.wait_until method to wait until the alert present  other wise you may get the 
   # No alert is active (Selenium::WebDriver::Error::NoAlertPresentError)
   #page.driver.browser.switch_to.alert.accept
   #page.driver.browser.switch_to.alert.dismiss
   click_link "test"
end

2 comments:

  1. How do you wait for the alert exactly?

    ReplyDelete
  2. This is what I use:

    page.driver.wait_until(page.driver.browser.switch_to.alert.dismiss)

    ReplyDelete